设置ActiveMQ的Redelivery Policy

本文介绍了如何配置ActiveMQ的Redelivery Policy,以详细控制消息重试的方式。内容涉及ActiveMQConnectionFactory和ActiveMQConnection上的设置,以及通过Java代码、Spring或连接配置URI进行定制的方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

 

Redelivery Policy

Detail on when messages are redelivered to a client can be found in the Message Redelivery and DLQ Handling section.

You can configure the RedeliveryPolicy on your ActiveMQConnectionFactory or ActiveMQConnection to customize exactly how you want the redelivery to work.

You can use Java code, Spring or the Connection Configuration URI to customise this.

Available Properties

Property

Default Value

Description

collisionAvoidanceFactor

0.15

The percentage of range of collision avoidance if enabled

maximumRedeliveries

6

Sets the maximum number of times a message will be redelivered before it is considered a poisoned pill and returned to the broker so it can go to a Dead Letter Queue (use value -1 to define infinite number of redeliveries)

maximumRedeliveryDelay

-1

Sets the maximum delivery delay that will be applied if the useExponentialBackOff option is set. (use value -1 to define that no maximum be applied) (v5.5)

initialRedeliveryDelay

1000L

The initial redelivery delay in milliseconds

redeliveryDelay

1000L

The delivery delay if initialRedeliveryDelay is 0 (v5.4)

useCollisionAvoidance

false

Should the redelivery policy use collision avoidance

useExponentialBackOff

false

Should exponential back-off be used (i.e. to exponentially increase the timeout)

backOffMultiplier

5

The back-off multiplier

 

 

参考网址:http://activemq.apache.org/redelivery-policy.html

### 配置 ActiveMQ 在 Windows 11 上开机自动启动 为了实现 ActiveMQ 在 Windows 11 开机时自动启动,可以通过将其设置为服务来完成。以下是详细的配置方法: #### 使用 Windows 服务管理器安装 ActiveMQ 作为服务 ActiveMQ 提供了一个内置工具 `activemq.bat` 来帮助用户将它注册为 Windows 的一项服务。 运行命令提示符(以管理员身份),进入 ActiveMQ 安装目录下的 bin 文件夹,并执行以下命令: ```cmd activemq install ``` 这会将 ActiveMQ 注册为一个 Windows 服务[^2]。完成后,可以使用以下命令启动该服务: ```cmd net start ApacheActiveMQ ``` #### 自动启动服务 要确保 ActiveMQ 在每次系统重启后都能自动启动,需调整其启动类型为“自动”。打开服务管理界面(通过运行 `services.msc` 打开),找到名为 **Apache ActiveMQ** 的条目,右键点击并选择属性,在“启动类型”下拉菜单中选择“自动”,最后保存更改[^3]。 #### 替代方案:任务计划程序 另一种方式是利用 Windows 的任务计划程序创建一个新的基本任务,设定触发条件为登录或启动计算机事件,动作则指向 ActiveMQ 启动脚本路径(通常是 `bin\win64\activemq.exe` 或者 `bin\activemq.bat`)。这种方法同样能达成目的但相对复杂一些[^4]。 以上两种途径均可满足需求,推荐优先考虑前者因其实现更为简便高效。 ```python import os def check_active_mq_service_status(): status = os.system('sc query ApacheActiveMQ') if 'RUNNING' in str(status): print("ActiveMQ is running.") else: print("ActiveMQ service not found or stopped.") check_active_mq_service_status() ```
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值