我尝试使用AMQP代替Openwire进行网络代理连接,但它对我不起作用。代理A以双工模式连接代理B和C.
经纪人A配置:
<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:amq="http://activemq.apache.org/schema/core"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core.xsd
http://activemq.apache.org/camel/schema/spring http://activemq.apache.org/camel/schema/spring/camel-spring.xsd">
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<value>file:${activemq.base}/conf/credentials.properties</value>
</property>
</bean>
<broker xmlns="http://activemq.apache.org/schema/core" brokerName="broker-A" networkConnectorStartAsync="true"
dataDirectory="${activemq.base}/data" schedulePeriodForDestinationPurge="60000" persistent="false">
<managementContext>
<managementContext createConnector="false"/>
</managementContext>
<destinationPolicy>
<policyMap>
<policyEntries>
<policyEntry queue=">" producerFlowControl="false" gcInactiveDestinations="true"
inactiveTimoutBeforeGC="300000" optimizedDispatch="true" useCache="false"/>
<policyEntry topic=">" producerFlowControl="false" optimizedDispatch="true"/>
</policyEntries>
</policyMap>
</destinationPolicy>
<networkConnectors>
<networkConnector
name="broker-B-topics"
uri="static:(tcp://broker-B:61616)"
duplex="true"
decreaseNetworkConsumerPriority="true"
dynamicOnly="true">
<excludedDestinations>
<queue physicalName=">"/>
</excludedDestinations>
<dynamicallyIncludedDestinations>
<topic physicalName="ActiveMQ.>"/>
<topic physicalName="testing.>"/>
</dynamicallyIncludedDestinations>
</networkConnector>
<networkConnector
name="broker-B-queues"
uri="static:(tcp://broker-B:61616)"
duplex="true"
decreaseNetworkConsumerPriority="true"
dynamicOnly="true"
conduitSubscriptions="false">
<excludedDestinations>
<topic physicalName=">"/>
</excludedDestinations>
<dynamicallyIncludedDestinations>
<queue physicalName="testing.>"/>
</dynamicallyIncludedDestinations>
</networkConnector>
<networkConnector
name="broker-C-topics"
uri="static:(tcp://broker-C:61616)"
duplex="true"
decreaseNetworkConsumerPriority="true"
dynamicOnly="true">
<excludedDestinations>
<queue physicalName=">"/>
</excludedDestinations>
<dynamicallyIncludedDestinations>
<topic physicalName="ActiveMQ.>"/>
<topic physicalName="testing.>"/>
</dynamicallyIncludedDestinations>
</networkConnector>
<networkConnector
name="broker-C-queues"
uri="static:(tcp://broker-C:61616)"
duplex="true"
decreaseNetworkConsumerPriority="true"
dynamicOnly="true"
conduitSubscriptions="false">
<excludedDestinations>
<topic physicalName=">"/>
</excludedDestinations>
<dynamicallyIncludedDestinations>
<queue physicalName="testing.>"/>
</dynamicallyIncludedDestinations>
</networkConnector>
</networkConnectors>
<systemUsage>
<systemUsage>
<memoryUsage>
<memoryUsage percentOfJvmHeap="70"/>
</memoryUsage>
<storeUsage>
<storeUsage limit="1 gb"/>
</storeUsage>
<tempUsage>
<tempUsage limit="1 gb"/>
</tempUsage>
</systemUsage>
</systemUsage>
<transportConnectors>
<transportConnector name="amqp" uri="amqp://0.0.0.0:61616"/>
<transportConnector name="stomp+nio" uri="stomp+nio://0.0.0.0:61613"/>
</transportConnectors>
</broker>
<import resource="jetty.xml"/>
</beans>
经纪人B配置:
<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core.xsd">
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<value>file:${activemq.conf}/credentials.properties</value>
</property>
</bean>
<bean id="logQuery" class="io.fabric8.insight.log.log4j.Log4jLogQuery"
lazy-init="false" scope="singleton"
init-method="start" destroy-method="stop">
</bean>
<broker xmlns="http://activemq.apache.org/schema/core" brokerName="broker-B" dataDirectory="${activemq.data}"
networkConnectorStartAsync="true" schedulePeriodForDestinationPurge="60000" persistent="false">
<destinationPolicy>
<policyMap>
<policyEntries>
<policyEntry queue=">" producerFlowControl="false" gcInactiveDestinations="true"
inactiveTimoutBeforeGC="300000" optimizedDispatch="true" useCache="false"/>
<policyEntry topic=">" producerFlowControl="false" optimizedDispatch="true"/>
</policyEntries>
</policyMap>
</destinationPolicy>
<plugins>
<timeStampingBrokerPlugin ttlCeiling="0" zeroExpirationOverride="0" futureOnly="true"/>
</plugins>
<managementContext>
<managementContext createConnector="false"/>
</managementContext>
<systemUsage>
<systemUsage>
<memoryUsage>
<memoryUsage percentOfJvmHeap="70"/>
</memoryUsage>
<storeUsage>
<storeUsage limit="1 gb"/>
</storeUsage>
<tempUsage>
<tempUsage limit="1 gb"/>
</tempUsage>
</systemUsage>
</systemUsage>
<transportConnectors>
<transportConnector name="amqp" uri="amqp://0.0.0.0:61616"/>
<transportConnector name="stomp+nio" uri="stomp+nio://0.0.0.0:61615"/>
</transportConnectors>
</broker>
</beans>
经纪人C配置:
<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core.xsd">
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<value>file:${activemq.conf}/credentials.properties</value>
</property>
</bean>
<bean id="logQuery" class="io.fabric8.insight.log.log4j.Log4jLogQuery"
lazy-init="false" scope="singleton"
init-method="start" destroy-method="stop">
</bean>
<broker xmlns="http://activemq.apache.org/schema/core" brokerName="broker-C" dataDirectory="${activemq.data}"
networkConnectorStartAsync="true" schedulePeriodForDestinationPurge="60000" persistent="false">
<destinationPolicy>
<policyMap>
<policyEntries>
<policyEntry queue=">" producerFlowControl="false" gcInactiveDestinations="true"
inactiveTimoutBeforeGC="300000" optimizedDispatch="true" useCache="false"/>
<policyEntry topic=">" producerFlowControl="false" optimizedDispatch="true"/>
</policyEntries>
</policyMap>
</destinationPolicy>
<plugins>
<timeStampingBrokerPlugin ttlCeiling="0" zeroExpirationOverride="0" futureOnly="true"/>
</plugins>
<managementContext>
<managementContext createConnector="false"/>
</managementContext>
<systemUsage>
<systemUsage>
<memoryUsage>
<memoryUsage percentOfJvmHeap="70"/>
</memoryUsage>
<storeUsage>
<storeUsage limit="1 gb"/>
</storeUsage>
<tempUsage>
<tempUsage limit="1 gb"/>
</tempUsage>
</systemUsage>
</systemUsage>
<transportConnectors>
<transportConnector name="amqp" uri="amqp://0.0.0.0:61616"/>
<transportConnector name="stomp+nio" uri="stomp+nio://0.0.0.0:61615"/>
</transportConnectors>
</broker>
</beans>
错误发生在经纪人A中的内容:
INFO | jvm 1 | 2018/01/18 22:25:45 | INFO | error with pending remote brokerInfo on: tcp://broker-B/xxx.xxx.xxx.xxx:61616@14953
INFO | jvm 1 | 2018/01/18 22:25:45 | java.io.IOException: Unknown data type: 80
INFO | jvm 1 | 2018/01/18 22:25:45 | at org.apache.activemq.openwire.OpenWireFormat.looseUnmarshalNestedObject(OpenWireFormat.java:471)[activemq-client-5.15.2.jar:5.15.2]
INFO | jvm 1 | 2018/01/18 22:25:45 | at org.apache.activemq.openwire.v12.BaseDataStreamMarshaller.looseUnmarsalCachedObject(BaseDataStreamMarshaller.java:487)[activemq-client-5.15.2.jar:5.15.2]
INFO | jvm 1 | 2018/01/18 22:25:45 | at org.apache.activemq.openwire.v12.ConnectionInfoMarshaller.looseUnmarshal(ConnectionInfoMarshaller.java:154)[activemq-client-5.15.2.jar:5.15.2]
INFO | jvm 1 | 2018/01/18 22:25:45 | at org.apache.activemq.openwire.OpenWireFormat.doUnmarshal(OpenWireFormat.java:367)[activemq-client-5.15.2.jar:5.15.2]
INFO | jvm 1 | 2018/01/18 22:25:45 | at org.apache.activemq.openwire.OpenWireFormat.unmarshal(OpenWireFormat.java:278)[activemq-client-5.15.2.jar:5.15.2]
INFO | jvm 1 | 2018/01/18 22:25:45 | at org.apache.activemq.transport.tcp.TcpTransport.readCommand(TcpTransport.java:240)[activemq-client-5.15.2.jar:5.15.2]
INFO | jvm 1 | 2018/01/18 22:25:45 | at org.apache.activemq.transport.tcp.TcpTransport.doRun(TcpTransport.java:232)[activemq-client-5.15.2.jar:5.15.2]
INFO | jvm 1 | 2018/01/18 22:25:45 | at org.apache.activemq.transport.tcp.TcpTransport.run(TcpTransport.java:215)[activemq-client-5.15.2.jar:5.15.2]
INFO | jvm 1 | 2018/01/18 22:25:45 | at java.lang.Thread.run(Thread.java:745)[:1.8.0_91]
INFO | jvm 1 | 2018/01/18 22:25:45 | INFO | error with pending remote brokerInfo on: tcp://broker-B/xxx.xxx.xxx.xxx:61616@14954
INFO | jvm 1 | 2018/01/18 22:25:45 | java.io.IOException: Unknown data type: 80
INFO | jvm 1 | 2018/01/18 22:25:45 | at org.apache.activemq.openwire.OpenWireFormat.looseUnmarshalNestedObject(OpenWireFormat.java:471)[activemq-client-5.15.2.jar:5.15.2]
INFO | jvm 1 | 2018/01/18 22:25:45 | at org.apache.activemq.openwire.v12.BaseDataStreamMarshaller.looseUnmarsalCachedObject(BaseDataStreamMarshaller.java:487)[activemq-client-5.15.2.jar:5.15.2]
INFO | jvm 1 | 2018/01/18 22:25:45 | at org.apache.activemq.openwire.v12.ConnectionInfoMarshaller.looseUnmarshal(ConnectionInfoMarshaller.java:154)[activemq-client-5.15.2.jar:5.15.2]
INFO | jvm 1 | 2018/01/18 22:25:45 | at org.apache.activemq.openwire.OpenWireFormat.doUnmarshal(OpenWireFormat.java:367)[activemq-client-5.15.2.jar:5.15.2]
INFO | jvm 1 | 2018/01/18 22:25:45 | at org.apache.activemq.openwire.OpenWireFormat.unmarshal(OpenWireFormat.java:278)[activemq-client-5.15.2.jar:5.15.2]
INFO | jvm 1 | 2018/01/18 22:25:45 | at org.apache.activemq.transport.tcp.TcpTransport.readCommand(TcpTransport.java:240)[activemq-client-5.15.2.jar:5.15.2]
INFO | jvm 1 | 2018/01/18 22:25:45 | at org.apache.activemq.transport.tcp.TcpTransport.doRun(TcpTransport.java:232)[activemq-client-5.15.2.jar:5.15.2]
INFO | jvm 1 | 2018/01/18 22:25:45 | at org.apache.activemq.transport.tcp.TcpTransport.run(TcpTransport.java:215)[activemq-client-5.15.2.jar:5.15.2]
INFO | jvm 1 | 2018/01/18 22:25:45 | at java.lang.Thread.run(Thread.java:745)[:1.8.0_91]
INFO | jvm 1 | 2018/01/18 22:25:45 | WARN | Network connection between vm://broker-A#0 and tcp://broker-B/xxx.xxx.xxx.xxx:61616@14953 shutdown due to a remote error: {}
INFO | jvm 1 | 2018/01/18 22:25:45 | java.util.concurrent.TimeoutException
INFO | jvm 1 | 2018/01/18 22:25:45 | at org.apache.activemq.network.DemandForwardingBridgeSupport$FutureBrokerInfo.get(DemandForwardingBridgeSupport.java:1828)[activemq-broker-5.15.2.jar:5.15.2]
INFO | jvm 1 | 2018/01/18 22:25:45 | at org.apache.activemq.network.DemandForwardingBridgeSupport.collectBrokerInfos(DemandForwardingBridgeSupport.java:388)[activemq-broker-5.15.2.jar:5.15.2]
INFO | jvm 1 | 2018/01/18 22:25:45 | at org.apache.activemq.network.DemandForwardingBridgeSupport.access$500(DemandForwardingBridgeSupport.java:113)[activemq-broker-5.15.2.jar:5.15.2]
INFO | jvm 1 | 2018/01/18 22:25:45 | at org.apache.activemq.network.DemandForwardingBridgeSupport$5.run(DemandForwardingBridgeSupport.java:366)[activemq-broker-5.15.2.jar:5.15.2]
INFO | jvm 1 | 2018/01/18 22:25:45 | at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)[:1.8.0_91]
INFO | jvm 1 | 2018/01/18 22:25:45 | at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)[:1.8.0_91]
INFO | jvm 1 | 2018/01/18 22:25:45 | at java.lang.Thread.run(Thread.java:745)[:1.8.0_91]
INFO | jvm 1 | 2018/01/18 22:25:45 | INFO | Network Connector DiscoveryNetworkConnector:broker-C-topics:BrokerService[broker-A] started
INFO | jvm 1 | 2018/01/18 22:25:45 | WARN | Network connection between vm://broker-A#6 and tcp://broker-B/xxx.xxx.xxx.xxx:61616@14954 shutdown due to a remote error: {}
INFO | jvm 1 | 2018/01/18 22:25:45 | java.util.concurrent.TimeoutException
INFO | jvm 1 | 2018/01/18 22:25:45 | at org.apache.activemq.network.DemandForwardingBridgeSupport$FutureBrokerInfo.get(DemandForwardingBridgeSupport.java:1828)[activemq-broker-5.15.2.jar:5.15.2]
INFO | jvm 1 | 2018/01/18 22:25:45 | at org.apache.activemq.network.DemandForwardingBridgeSupport.collectBrokerInfos(DemandForwardingBridgeSupport.java:388)[activemq-broker-5.15.2.jar:5.15.2]
INFO | jvm 1 | 2018/01/18 22:25:45 | at org.apache.activemq.network.DemandForwardingBridgeSupport.access$500(DemandForwardingBridgeSupport.java:113)[activemq-broker-5.15.2.jar:5.15.2]
INFO | jvm 1 | 2018/01/18 22:25:45 | at org.apache.activemq.network.DemandForwardingBridgeSupport$5.run(DemandForwardingBridgeSupport.java:366)[activemq-broker-5.15.2.jar:5.15.2]
INFO | jvm 1 | 2018/01/18 22:25:45 | at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)[:1.8.0_91]
INFO | jvm 1 | 2018/01/18 22:25:45 | at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)[:1.8.0_91]
INFO | jvm 1 | 2018/01/18 22:25:45 | at java.lang.Thread.run(Thread.java:745)[:1.8.0_91]
INFO | jvm 1 | 2018/01/18 22:25:45 | INFO | Network Connector DiscoveryNetworkConnector:broker-C-queues:BrokerService[broker-A] started
INFO | jvm 1 | 2018/01/18 22:25:45 | INFO | broker-A bridge to Unknown stopped
INFO | jvm 1 | 2018/01/18 22:25:45 | INFO | broker-A bridge to Unknown stopped
INFO | jvm 1 | 2018/01/18 22:25:45 | at org.apache.activemq.network.DemandForwardingBridgeSupport.collectBrokerInfos(DemandForwardingBridgeSupport.java:388)[activemq-broker-5.15.2.jar:5.15.2]
INFO | jvm 1 | 2018/01/18 22:25:45 | at org.apache.activemq.network.DemandForwardingBridgeSupport.access$500(DemandForwardingBridgeSupport.java:113)[activemq-broker-5.15.2.jar:5.15.2]
INFO | jvm 1 | 2018/01/18 22:25:45 | at org.apache.activemq.network.DemandForwardingBridgeSupport$5.run(DemandForwardingBridgeSupport.java:366)[activemq-broker-5.15.2.jar:5.15.2]
INFO | jvm 1 | 2018/01/18 22:25:45 | at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)[:1.8.0_91]
INFO | jvm 1 | 2018/01/18 22:25:45 | at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)[:1.8.0_91]
INFO | jvm 1 | 2018/01/18 22:25:45 | at java.lang.Thread.run(Thread.java:745)[:1.8.0_91]
不确定为什么它连接不正确。基于另一个线程http://activemq.2283324.n4.nabble.com/Unable-to-configure-Network-of-brokers-successfully-with-AMQP-td4689623.html,需要为网络连接配置Openwire协议。
答案 0 :(得分:0)
您无法执行此操作,您需要使用基于OpenWire的连接来进行代理之间的网络连接。 ActiveMQ支持AMQP客户端,但对于网络,您必须使用ActiveMQ OpenWire连接,不支持其他网络连接。