You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

ActiveMQ Artemis+STOMP:队列消息被多消费者重复消费问题咨询

ActiveMQ Artemis 2.27 重复消费问题的Broker端配置优化方案

核心配置调整建议

1. 杜绝连接ID复用导致的消费者身份混淆

由于消费者固定使用相同connection_id,Broker可能将多个Pod的连接识别为同一消费者实例,引发重复分发。在STOMP协议的acceptor配置中添加重复连接ID拦截:

<acceptor name="stomp-acceptor">tcp://0.0.0.0:61613?protocols=STOMP;reject-duplicate-connection-ids=true</acceptor>

同时配置连接超时清理,确保断开的连接被及时回收:

<address-setting match="#">
    <connection-ttl>30000</connection-ttl> <!-- 30秒连接超时 -->
    <connection-ttl-check-interval>10000</connection-ttl-check-interval> <!-- 每10秒检查一次 -->
</address-setting>

2. 启用消息锁定机制

针对目标ANYCAST队列开启严格的消息锁定,确保消息被分发后立即锁定,直到ACK完成才释放:

<address-setting match="你的目标队列名称">
    <lock-on-delivery>true</lock-on-delivery>
    <unlock-on-acknowledge>true</unlock-on-acknowledge>
    <max-delivery-attempts>1</max-delivery-attempts> <!-- 关闭重试避免重复分发 -->
    <strict-update-counter>true</strict-update-counter> <!-- 强制严格更新消息状态计数器 -->
</address-setting>

3. 强化ACK操作的可靠性

由于使用client-individual ack模式,需确保ACK操作被持久化,避免Broker故障导致消息状态丢失:

<core>
    <persistence-enabled>true</persistence-enabled>
    <journal-sync-non-transactional>true</journal-sync-non-transactional> <!-- 非事务ACK立即同步到磁盘 -->
</core>

4. 配合消费者端的补充说明

虽然需求聚焦Broker端配置,但需确保消费者进程在ACK后立即关闭连接,避免同一connection_id下的残留会话导致Broker误判;同时多进程处理消息时,需保证每个进程使用独立的STOMP连接。

内容的提问来源于stack exchange,提问作者Amit

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.14 01:24:54