我通过在代理URL
中使用以下模式来使用故障转移传输功能failover:(tcp://host:port)
初始化代码如下:
factory = new PooledConnectionFactory(BROKER_URL);
connection = factory.createConnection();
connection.start();
put消息代码看起来或多或少像这样:
session = connection.createSession( false, Session.AUTO_ACKNOWLEDGE );
Destination destQueue = new ActiveMQQueue(queue);
MessageProducer producer = session.createProducer(destQueue);
TextMessage msg = session.createTextMessage(message);
producer.send(msg);
发生故障转移时 -
[org.apache.activemq.transport.failover.FailoverTransport] Transport (broker) failed, reason: , attempting to automatically reconnect: java.net.SocketException: recv failed: Connection aborted by peer
and got reconnected after
[org.apache.activemq.transport.failover.FailoverTransport] Failed to connect to [broker] after: 10 attempt(s) continuing to retry.
08:55:29,596 INFO [org.apache.activemq.transport.failover.FailoverTransport] Successfully reconnected to broker
我必须重新启动连接吗?或者更具体一点,我是否必须对连接对象执行任何操作才能在故障转移后生成/使用消息?
感谢
答案 0 :(得分:0)
故障转移传输的重点是为您处理重新连接。您显示的日志表明成功的重新连接周期,其中传输继续重试以连接到代理并最终执行此操作。