ActiveMQ配置详解之如何配置自动重新连接

本文详细介绍了ActiveMQ的Failover Transport配置,包括配置语法、传输选项、URI示例、事务处理和broker端的故障转移选项,旨在确保在传输层实现自动重新连接和故障恢复。
摘要由CSDN通过智能技术生成
ActiveMQ配置详解之如何配置自动重新连接 博客分类: MQ
这从这一篇开始,将讲解在activeMQ中的相关配置。由于activeMQ主要是参考apache官方网站上的说明,并在适当的地方加注说明。
一、如何配置自动重新连接
Apache官方说明:
If a JMS broker goes down, ActiveMQ can automatically reconnect to an available JMS broker using the failover:  protocol. Not only does this automatically reconnect, it will also resume any temporary destinations, sessions, producers and most importantly consumers.
All of this happens silently inside the JMS client so you don't need to worry about it in your application code.
e.g. connecting to the URL
failover:tcp: < span  class=code-comment >//host1:port1,tcp://host2:port2
关于Failover的更为详细的说明如下:

The Failover(故障转移) Transport(注:这里自然可以翻译为“传输”,但是从根本上来说,我认为主要是在于故障转移是在传输层完成

The Failover transport layers reconnect logic on top of any of the other transports. (We used to call this transport the Reliable transport in ActiveMQ 3).
The Failover configuration syntax allows you to specify any number of composite uris. The Failover transport randomly chooses one of the composite URI and attempts to establish a connection to it. If it does not succeed or if it subsequently fails, a new connection is established to one of the other uris in the list.
Configuration Syntax
failover:(uri1,...,uriN)?transportOptions
or
failover:uri1,...,uriN
The failover transport uses random by default which lets you to load balance clients over a number of brokers.
If you would rather connect to a primary first and only connect to a secondary backup broker if the primary is unavailable, turn off randomizing using something like
failover:(tcp://primary:61616,tcp://secondary:61616)?randomize=false
这些下面的这些参数都可以通过类似http参数传值的方式failover:(tcp://host1:61616,tcp://host2:61616,...)?p1=v1&p2=v2&p3=v3
将参数p1,p2,p3传入。
Transport Options
initialReconnectDelay 10 How long to wait before the first reconnect attempt (in ms)
maxReconnectDelay 30000 The maximum amount of time we ever wait between reconnect attempts (in ms)
useExponentialBackOff true Should an exponential backoff be used btween reconnect attempts (在尝试重新连接时是否使用指数回退算法
backOffMultiplie
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值