ActiveMQ 纯主/从 - 不同步

ActiveMQ 纯主/从 - 不同步
  • 我拥有:1 个主代理和 1 个从属代理,均采用 ActiveMQ 5.4.0

    • 我使用的内容:主端的 waitForSlave 和从端的故障转移 uri(在主连接器 URI 中)

    • 我想要做的:在启动从属传输连接器之前,我想等待一段时间(例如 5 秒),以防主从之间出现微小的网络故障

所以我把它放在从属配置中:

<broker xmlns="http://activemq.apache.org/schema/core" 
 brokerName="slave" 
 dataDirectory="${activemq.base}/data" 
 useJmx="true" 
 persistent="true" 
 populateJMSXUserID="true"
 masterConnectorURI="failover://(tcp://master:61616)?initialReconnectDelay=1000&amp;maxReconnectDelay=30000"
 shutdownOnMasterFailure="false"
 advisorySupport="false">

它似乎工作正常,但是在主服务器和从服务器之间出现网络挂起后,从服务器成功重新连接,然后主服务器记录大量信息:

2010-10-18 17:08:44,421 | ERROR | Slave Failed | org.apache.activemq.broker.ft.MasterBroker | ActiveMQ Task
java.lang.IllegalStateException: Cannot lookup a connection that had not been registered: ID:master-1040-634226732611718750-0:0
 at org.apache.activemq.broker.MapTransportConnectionStateRegister.lookupConnectionState(MapTransportConnectionStateRegister.java:93)
 at org.apache.activemq.broker.TransportConnection.lookupConnectionState(TransportConnection.java:1412)
 at org.apache.activemq.broker.TransportConnection.processRemoveConsumer(TransportConnection.java:561)
 at org.apache.activemq.command.RemoveInfo.visit(RemoveInfo.java:76)
 at org.apache.activemq.broker.TransportConnection.service(TransportConnection.java:309)
 at org.apache.activemq.broker.TransportConnection$1.onCommand(TransportConnection.java:185)
 at org.apache.activemq.transport.ResponseCorrelator.onCommand(ResponseCorrelator.java:116)
 at org.apache.activemq.transport.TransportFilter.onCommand(TransportFilter.java:69)
 at org.apache.activemq.transport.vm.VMTransport.iterate(VMTransport.java:218)
 at org.apache.activemq.thread.DedicatedTaskRunner.runTask(DedicatedTaskRunner.java:98)
 at org.apache.activemq.thread.DedicatedTaskRunner$1.run(DedicatedTaskRunner.java:36)

从服务器端一切正常。因此,此后,我尝试停止主服务器,以查看在这些“网络挂起”之后从服务器是否能够转为主服务器。

主服务器花了很长时间关闭(10 秒),然后从属日志中出现一些错误消息:

2010-10-18 17:09:32,915 | WARN  | Async error occurred: java.lang.IllegalStateException: Cannot lookup a connection that had not been registered: ID:master-1049-634226732657812500-0:3 | org.apache.activemq.broker.TransportConnection.Service | VMTransport: vm://slave#5
java.lang.IllegalStateException: Cannot lookup a connection that had not been registered: ID:master-1049-634226732657812500-0:3
 at org.apache.activemq.broker.MapTransportConnectionStateRegister.lookupConnectionState(MapTransportConnectionStateRegister.java:93)
 at org.apache.activemq.broker.TransportConnection.lookupConnectionState(TransportConnection.java:1412)
 at org.apache.activemq.broker.TransportConnection.processRemoveSession(TransportConnection.java:600)
 at org.apache.activemq.command.RemoveInfo.visit(RemoveInfo.java:74)
 at org.apache.activemq.broker.TransportConnection.service(TransportConnection.java:309)
 at org.apache.activemq.broker.TransportConnection$1.onCommand(TransportConnection.java:185)
 at org.apache.activemq.transport.ResponseCorrelator.onCommand(ResponseCorrelator.java:116)
 at org.apache.activemq.transport.TransportFilter.onCommand(TransportFilter.java:69)
 at org.apache.activemq.transport.vm.VMTransport.iterate(VMTransport.java:218)
 at org.apache.activemq.thread.DedicatedTaskRunner.runTask(DedicatedTaskRunner.java:98)
 at org.apache.activemq.thread.DedicatedTaskRunner$1.run(DedicatedTaskRunner.java:36)

有什么方法可以让我的 kaha 商店(它们是单独的商店)保持同步吗?主要问题是主服务器发生故障后,从服务器永远不会变成主服务器,它会一直阻塞在这条消息上:

2010-10-18 17:09:33,681 | WARN  | Transport (master/172.21.60.61:61616) failed to tcp://master:61616 , attempting to automatically reconnect due to: java.net.SocketException: Software caused connection abort: socket write error | org.apache.activemq.transport.failover.FailoverTransport | ActiveMQ Transport: tcp://master/172.21.60.61:61616

我完全被这些同步问题困扰了,欢迎任何帮助!

问候

答案1

经过大量测试后,似乎无法利用我们当前的基础设施/环境来实现我想要的功能。

这可以与共享数据存储一起工作,但是每个代理都有一个唯一的数据存储,因此我总是不同步。

相关内容