ActiveMQ故障转移超时随机工作

问题描述:

我遇到了超时故障转移选项的问题。 基本上我想要一个不断发送消息给经纪人的客户,如果经纪人关闭了,他会尝试重新连接,直到经纪人重新开始。同时,发送将超时,所以它不会永远在那里等待。ActiveMQ故障转移超时随机工作

但是,经过一些测试,看起来超时选项无法正常工作。 有时候,它确实超时,但有时它只是挂在那里。 我知道另一个选项是maxReconnectAttempt。但事情是我想让它尝试永久重新连接。

下面是我使用的网址:

failover:(tcp://10.5.0.198:61616)?timeout=1000 

我有一个双服务器系统。一个作为经纪人,一个作为客户。当我切换经纪人开始/停止,我得到下面的日志消息:

We sent a Message! 
2016-02-24 20:29:06,967 [198:[email protected]] - WARN FailoverTransport - Transport (tcp://10.5.0.198:61616) failed, reason: java.io.EOFException, attempting to automatically reconnect 
Failover timeout of 1000 ms reached. 
Failover timeout of 1000 ms reached. 
Failover timeout of 1000 ms reached. 
Failover timeout of 1000 ms reached. 
Failover timeout of 1000 ms reached. 
Failover timeout of 1000 ms reached. 
We sent a Message! 
We sent a Message! 
We sent a Message! 
We sent a Message! 
We sent a Message! 
2016-02-24 20:29:48,688 [198:[email protected]] - WARN FailoverTransport - Transport (tcp://10.5.0.198:61616) failed, reason: java.io.EOFException, attempting to automatically reconnect 
We sent a Message! 
We sent a Message! 
We sent a Message! 
We sent a Message! 
We sent a Message! 
2016-02-24 21:57:50,777 [198:[email protected]] - WARN FailoverTransport - Transport (tcp://10.5.0.198:61616) failed, reason: java.io.EOFException, attempting to automatically reconnect 
Failover timeout of 1000 ms reached. 
Failover timeout of 1000 ms reached. 
Failover timeout of 1000 ms reached. 

正如你可以看到,当经纪人下跌,第二次,它没有超时一个多小时。

下面是我使用的代码:

​​

我想不出这一点。经过一番研究,AMQ似乎是一个问题。

所以为了不阻塞整个事情,我切换到提供本地缓冲区的网络代理,因此当它重试时,发送操作将继续。

这是我现在可以找到的最佳解决方案。