消息 "in delivery" 状态未在 ActiveMQ Artemis 代理上发布

Messages "in delivery" status not released on ActiveMQ Artemis broker

我已经在主从配置上设置了两个 ActiveMQ Artemis 代理(版本 2.17),并使用共享文件系统实现 HA。在测试期间 繁忙的交通我会停止主经纪人并看到奴隶接管并开始向消费者转发消息。过了一会儿 我可以看到许多消息似乎被困在队列中。我可以将“卡住”消息视为“正在传递” 查询时从 Artemis UI 查看。

我的问题是,即使我重新启动主代理,这些消息也不会传递给消费者,并且即使有更多消息也会卡住 消息仍在填充同一个队列,并且该队列有消费者。我的假设是它与以前的连接有关 消费者设置仍然有效,因为没有确认。

所以我确实尝试在代理或客户端连接字符串上设置 <connection-ttl-override> (tcp://host1:61616,tcp://host2:61616)?ha=true&connectionTtl=60000&reconnectAttempts=-1) 但这似乎没有任何效果 因为连接不会关闭并且消息不会被释放。 对于消费消息,我正在使用带有 CachingConnectionFactory 的 Artemis JMS Spring 客户端,但也尝试了 JmsPoolConnectionFactory 无济于事。

<bean id="connectionFactory"
    class="org.springframework.jms.connection.CachingConnectionFactory">
    <property name="targetConnectionFactory">
          <bean  class="org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory">
                 <property name="user" value="${spring.artemis.user}" />
                 <property name="password" value="${spring.artemis.password}" />
                 <property name="brokerURL" value="${spring.artemis.brokerUrl}" />
           </bean>
     </property>
     <property name="cacheConsumers" value="false"/>
</bean>

<int-jms:message-driven-channel-adapter
     connection-factory="connectionFactory"
     destination="myQueue"
     message-converter="messageConverter"
     channel="inputChannel"
     concurrent-consumers="${processing.poolsize}"
     max-concurrent-consumers="${max.processing.poolsize}"
     error-channel="errorChannel"
     acknowledge="transacted"
/>

解决此问题的唯一方法似乎是重新启动取消阻止消息的消费者应用程序,但这不是理想的选择。

我该如何解决这个问题?有没有办法在不手动干预或重新启动消费者应用程序的情况下释放消息?

CachingConnectionFactory 使用变量并发可能是问题所在。

当“空闲”消费者返回缓存时,代理不知道消费者不活跃,仍然向它发送消息。

实际上只有生产者端(JmsTemplate)才需要缓存工厂,以避免为每次发送创建连接和会话。

如果使用可变并发,最好不要使用CCF;或将其配置为不缓存消费者,或不使用可变并发。