ActiveMQ 从客户端连接之前发送的队列接收消息
ActiveMQ receiving messages from a queue sent before client get connected
在我的场景中,生产者正在向队列发送消息(像往常一样:) 但其中一个消费者不时关闭,因此我必须能够在消费者关闭时读取发送到该队列的所有消息。换句话说,我正在寻找消息或整个服务器的配置,允许在消费者重新连接后接收消息,而消息是预先发送的。
更准确地说,当客户端重新连接时,它无法接收队列中待处理的消息。我需要的是强制新连接的客户端接收队列中已经挂起的消息,以帮助其他客户端排空队列。
这是定义的正常行为,发送到队列的消息仍然处于待处理状态,如果没有消费者连接则不会丢失。
更新
所以我认为您的问题是 prefetchPolicy。
persistent queues (default value: 1000)
non-persistent queues (default value: 1000)
persistent topics (default value: 100)
non-persistent topics (default value: Short.MAX_VALUE - 1)
所以我认为所有消息都已发送给已连接的消费者,当另一个消费者连接时他不会收到消息,因此如果队列有并发消费者,则要更改此行为,您需要将 prefetchPolicy 设置为较低的值值高于默认值。例如将此 jms.prefetchPolicy.queuePrefetch=1
添加到 activemq.xml 中的 uri 配置或在客户端 url.
中设置它
Large prefetch values are recommended for high performance with high
message volumes. However, for lower message volumes, where each
message takes a long time to process, the prefetch should be set to 1.
This ensures that a consumer is only processing one message at a time.
Specifying a prefetch limit of zero, however, will cause the consumer
to poll for messages, one at a time, instead of the message being
pushed to the consumer.
看看http://activemq.apache.org/what-is-the-prefetch-limit-for.html
和
在我的场景中,生产者正在向队列发送消息(像往常一样:) 但其中一个消费者不时关闭,因此我必须能够在消费者关闭时读取发送到该队列的所有消息。换句话说,我正在寻找消息或整个服务器的配置,允许在消费者重新连接后接收消息,而消息是预先发送的。
更准确地说,当客户端重新连接时,它无法接收队列中待处理的消息。我需要的是强制新连接的客户端接收队列中已经挂起的消息,以帮助其他客户端排空队列。
这是定义的正常行为,发送到队列的消息仍然处于待处理状态,如果没有消费者连接则不会丢失。
更新
所以我认为您的问题是 prefetchPolicy。
persistent queues (default value: 1000)
non-persistent queues (default value: 1000)
persistent topics (default value: 100)
non-persistent topics (default value: Short.MAX_VALUE - 1)
所以我认为所有消息都已发送给已连接的消费者,当另一个消费者连接时他不会收到消息,因此如果队列有并发消费者,则要更改此行为,您需要将 prefetchPolicy 设置为较低的值值高于默认值。例如将此 jms.prefetchPolicy.queuePrefetch=1
添加到 activemq.xml 中的 uri 配置或在客户端 url.
Large prefetch values are recommended for high performance with high message volumes. However, for lower message volumes, where each message takes a long time to process, the prefetch should be set to 1. This ensures that a consumer is only processing one message at a time. Specifying a prefetch limit of zero, however, will cause the consumer to poll for messages, one at a time, instead of the message being pushed to the consumer.
看看http://activemq.apache.org/what-is-the-prefetch-limit-for.html
和