使用 activemq 故障转移 URI 重新连接,而首次连接超时
我目前正在使用 activemq 故障转移 uir 来让客户端重新连接到代理,而且我也不这样做 希望“发送”操作在断开连接时被阻止,所以我使用像 failover:(tcp://192.168.193.177:61616)?timeout=1
这样的 URI,而问题是我是否可以第一次无法连接,连接会超时,重新连接也不起作用,我得到的异常是:
2011 年 12 月 7 日下午 3:39:28 org.apache.activemq.transport.failover.FailoverTransport oneway 信息:故障转移在 2 毫秒后超时 2011 年 12 月 7 日下午 3:39:28 org.apache.activemq.transport.failover.FailoverTransport doReconnect 信息:已成功连接到 tcp://127.0.0.1:61616 线程“pool-1-thread-2”中的异常 java.lang.NullPointerException 在com.cicc.mdf.dataserver.messaging.JMSMessagePublisher.publish(JMSMessagePublisher.java:197) 在com.cicc.mdf.dataserver.messaging.JMSMessagePublisher.publishRealTimeData(JMSMessagePublisher.java:270) 在 com.cicc.mdf.dataserver.service.MarketDataService.process(MarketDataService.java:984) 在 com.cicc.mdf.message.parser.BroadcastMessageParser.parseElement(BroadcastMessageParser.java:219) 在 com.cicc.mdf.connectivity.RawDataParser.slice(RawDataParser.java:433) 在 com.cicc.mdf.connectivity.RawDataParser.run(RawDataParser.java:110) 在 java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) 在 java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
我认为超时参数仅适用于发送操作而不会干扰重新连接,但是第一次连接?
编辑:如果java客户端第一次成功连接到代理,那么如果连接断开,发送操作将在连接未建立时超时,并且java客户端将重新连接到代理,这就是我所期望的。 而如果java客户端第一次无法成功连接到代理,连接将超时,直到成功才尝试重新连接,这是我意想不到的,我是否有什么地方错了?
编辑:Activemq 版本:5.3.0
编辑:抱歉,URI 有效,这是我的错误,我对另一个异常感到困惑,
知道吗?
谢谢
ps:这是我第一次上 Stackoverflow,如有不合常规的地方,请指正
I am currently using activemq failover uir for client reconnecting to the broker, and I also don't
want "send" operation to be blocked when it disconnect, so I am using URI likefailover:(tcp://192.168.193.177:61616)?timeout=1
, while the problem is if I can't get connection for the first time, the connecting will time out and the reconnecting doesn't work, the exception I got:
Dec 7, 2011 3:39:28 PM org.apache.activemq.transport.failover.FailoverTransport oneway
INFO: Failover timed out after 2ms
Dec 7, 2011 3:39:28 PM org.apache.activemq.transport.failover.FailoverTransport doReconnect
INFO: Successfully connected to tcp://127.0.0.1:61616
Exception in thread "pool-1-thread-2" java.lang.NullPointerException
at com.cicc.mdf.dataserver.messaging.JMSMessagePublisher.publish(JMSMessagePublisher.java:197)
at com.cicc.mdf.dataserver.messaging.JMSMessagePublisher.publishRealTimeData(JMSMessagePublisher.java:270)
at com.cicc.mdf.dataserver.service.MarketDataService.process(MarketDataService.java:984)
at com.cicc.mdf.message.parser.BroadcastMessageParser.parseElement(BroadcastMessageParser.java:219)
at com.cicc.mdf.connectivity.RawDataParser.slice(RawDataParser.java:433)
at com.cicc.mdf.connectivity.RawDataParser.run(RawDataParser.java:110)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
I thought the timeout parameter only works on send operation without interfere with reconnecting, but the first connecting?
EDIT: if the java client connected to the broker successfully for the first time, then if connection got disconnected, send operation will time out when connection don't established, and java client will reconnect to the broker, that what i am expected.
while if java client can't connect to the broker successfully for the first time, the connecting will time out, not trying to reconnect till successfully that what i am unexpected, am I some place wrong?
EDIT: Activemq version: 5.3.0
EDIT: Sorry, the URI is valid, it's my mistake, I was confused by another exception
any idea?
Thanks
ps: this is my first time on Stackoverflow, any unconventional behalve, pls correct it
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的 URI 似乎有效。您能解释一下“重新连接不起作用”是什么意思吗?指数回退是否会增加得如此之多,以至于您认为它不会重新连接?
您可以禁用它并重试:
请包含您客户端的一些日志,我们可能会获得有关重新连接不起作用的原因的更多信息。
您使用的 ActiveMQ 客户端是什么?爪哇? C++? C#?
Your URI seems valid. Can you explain maybe what do you mean by "the reconnecting doesn't work"? Might it be that the exponential back off increases so much you think it doesn't reconnect?
You can disable it and try again:
Please include a bit of logs of your client, we might get more information on why the reconnecting doesn't work.
What is the ActiveMQ client you are using? Java? C++? C#?