简体   繁体   English

配置ActiveMQ进行负载平衡和重新连接

[英]Configuring ActiveMQ to load balance and reconnect

Using Java how do i configure ActiveMQ to load balance and reconnect when disconnection occur? 使用Java如何将ActiveMQ配置为负载平衡并在断开连接时重新连接?

As i understand those configuration should be made on the ActiveMQConnectionFactory object. 据我了解,这些配置应在ActiveMQConnectionFactory对象上进行。

To do that, you set the brokerUrl of the ActiveMQConnectionFactory to a failover transport URI ; 为此,请将ActiveMQConnectionFactory的brokerUrl设置为故障转移传输URI

failover:(tcp://primary:61616,tcp://secondary:61616)

If you only have one broker, the below should be enough, ok for testing of reconnects but for production you'll most likely want more than one; 如果您只有一个经纪人,那么下面的内容就足够了,可以测试重新连接,但是对于生产而言,您很可能需要多个经纪人。

failover:(tcp://primary:61616)

Unlimited reconnection attempts is the default, but you can tweak quite a few options if you look at the documentation linked above. 无限制的重新连接尝试是默认的尝试,但是如果您查看上面链接的文档,则可以调整很多选项。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM