队列消费者有待处理的消息,但未得到处理

Queue Consumers have pending messages but they are not getting processed

我正在使用 activemq、camel 和 spring 的组合。对于队列,我们​​有多个消费者;在一些队列消费者上,我们看到有待处理的消息(上升到 100,这与预取相同)并且它们根本没有得到处理,但同一队列的其他消费者,一切照常。

我深入了解发生了什么,发现 spring cachingconnectionfactory 可能导致了这个问题 - 我们怀疑这个缓存连接工厂可能使一些客户端处于非活动状态并且消息留在它们的预取缓冲区中没有得到处理。我们的发现是否正确?

除此之外,我们有什么方法可以从非活动消费者释放的预取缓冲区中获取消息?

您不得使用具有可变并发性的 CachingConnectionFactory,或者您必须禁用消费者缓存;请参阅 DefaultMessageListenerContainer.

的 javadoc
 * <p><b>Note: Don't use Spring's {@link org.springframework.jms.connection.CachingConnectionFactory}
 * in combination with dynamic scaling.</b> Ideally, don't use it with a message
 * listener container at all, since it is generally preferable to let the
 * listener container itself handle appropriate caching within its lifecycle.

否则空闲的消费者会被放入缓存。