如何设置 ActiveMQ.DLQ 队列的到期时间?
how to set expiry for ActiveMQ.DLQ queue?
作为运营人员(不是开发人员),基于 http://activemq.apache.org/message-redelivery-and-dlq-handling.html,我尝试在集成到 JBoss Fuse 6.2 中的 ActiveMQ.DLQ 上设置到期时间,以确保KahaDB 的文件夹不会超出磁盘 space 但下面的设置似乎对队列消息没有任何作用,而是将它们复制到 ActiveMQ.Advisory.Producer.Queue.ActiveMQ.DLQ 两次。
...
<policyEntry queue=">" producerFlowControl="false">
<deadLetterStrategy>
<sharedDeadLetterStrategy expiration="300000"/>
</deadLetterStrategy>
</policyEntry>
...
为了测试这只是使用 JBOSS FUSE MANAGEMENT CONSOLE 将消息发送到 ActiveMQ.DLQ 队列,并注意到生成了一个新队列,其中包含我发送的消息数量的两倍排队:
ActiveMQ.Advisory.Producer.Queue.ActiveMQ.DLQ 0 0 0 8 0 0
ActiveMQ.DLQ 4 0 0 4 0 0
有什么想法吗?
过期消息的默认操作是将其发送到 DLQ。您需要避免处理过期消息,这意味着:丢弃它们。在您的 DLQ 上添加 processExpired="false"
应该可以解决问题。
(引自http://activemq.apache.org/message-redelivery-and-dlq-handling.html)
To tell ActiveMQ to just discard expired messages, configure the processExpired property to false on a dead letter strategy:
<broker...>
<destinationPolicy>
<policyMap>
<policyEntries>
<!-- Set the following policy on all queues using the '>' wildcard -->
<policyEntry queue=">">
<!--
Tell the dead letter strategy not to process expired messages
so that they will just be discarded instead of being sent to
the DLQ
-->
<deadLetterStrategy>
<sharedDeadLetterStrategy processExpired="false" />
</deadLetterStrategy>
</policyEntry>
</policyEntries>
</policyMap>
</destinationPolicy>
...
</broker>
你的 deadLetterStrategy
很好,必须工作正常,但你不能这样测试,因为过期是由尝试传递给消费者的业务代码设置的,当它失败时,它将消息发送到DLQ 通过更改它们的到期时间。
例如,您可以通过将 setJMSExpiration
(生存时间)设置为 1 来向您想要的任何队列发送消息来进行测试,这样,如果 processExpired="true"
,消息将不会被传递并直接发送到 DLQ .
ActiveMQ.Advisory.Producer.Queue.ActiveMQ.DLQ
的创建是因为您有一个向 ActiveMQ.DLQ
发送消息的生产者。
因为你已经向 ActiveMQ.DLQ
发送了 4 条消息,你在 ActiveMQ.Advisory.Producer.Queue.ActiveMQ.DLQ
中有 8 条消息,因为这个主题在生产者开始时收到一条消息,而在它停止消息时收到另一条消息,这意味着你的 JBOSS FUSE MANAGEMENT CONSOLE 创建连接以发送消息并在之后停止。
请注意,默认情况下,ActiveMQ 永远不会过期发送到 DLQ 的消息,如果您想将它们保留 7 天,您可以设置 <sharedDeadLetterStrategy expiration="604800000" processExpired="true" processNonPersistent="true" />
http://activemq.apache.org/advisory-message.html
http://activemq.apache.org/message-redelivery-and-dlq-handling.html
作为运营人员(不是开发人员),基于 http://activemq.apache.org/message-redelivery-and-dlq-handling.html,我尝试在集成到 JBoss Fuse 6.2 中的 ActiveMQ.DLQ 上设置到期时间,以确保KahaDB 的文件夹不会超出磁盘 space 但下面的设置似乎对队列消息没有任何作用,而是将它们复制到 ActiveMQ.Advisory.Producer.Queue.ActiveMQ.DLQ 两次。
...
<policyEntry queue=">" producerFlowControl="false">
<deadLetterStrategy>
<sharedDeadLetterStrategy expiration="300000"/>
</deadLetterStrategy>
</policyEntry>
...
为了测试这只是使用 JBOSS FUSE MANAGEMENT CONSOLE 将消息发送到 ActiveMQ.DLQ 队列,并注意到生成了一个新队列,其中包含我发送的消息数量的两倍排队:
ActiveMQ.Advisory.Producer.Queue.ActiveMQ.DLQ 0 0 0 8 0 0
ActiveMQ.DLQ 4 0 0 4 0 0
有什么想法吗?
过期消息的默认操作是将其发送到 DLQ。您需要避免处理过期消息,这意味着:丢弃它们。在您的 DLQ 上添加 processExpired="false"
应该可以解决问题。
(引自http://activemq.apache.org/message-redelivery-and-dlq-handling.html)
To tell ActiveMQ to just discard expired messages, configure the processExpired property to false on a dead letter strategy:
<broker...>
<destinationPolicy>
<policyMap>
<policyEntries>
<!-- Set the following policy on all queues using the '>' wildcard -->
<policyEntry queue=">">
<!--
Tell the dead letter strategy not to process expired messages
so that they will just be discarded instead of being sent to
the DLQ
-->
<deadLetterStrategy>
<sharedDeadLetterStrategy processExpired="false" />
</deadLetterStrategy>
</policyEntry>
</policyEntries>
</policyMap>
</destinationPolicy>
...
</broker>
你的 deadLetterStrategy
很好,必须工作正常,但你不能这样测试,因为过期是由尝试传递给消费者的业务代码设置的,当它失败时,它将消息发送到DLQ 通过更改它们的到期时间。
例如,您可以通过将 setJMSExpiration
(生存时间)设置为 1 来向您想要的任何队列发送消息来进行测试,这样,如果 processExpired="true"
,消息将不会被传递并直接发送到 DLQ .
ActiveMQ.Advisory.Producer.Queue.ActiveMQ.DLQ
的创建是因为您有一个向 ActiveMQ.DLQ
发送消息的生产者。
因为你已经向 ActiveMQ.DLQ
发送了 4 条消息,你在 ActiveMQ.Advisory.Producer.Queue.ActiveMQ.DLQ
中有 8 条消息,因为这个主题在生产者开始时收到一条消息,而在它停止消息时收到另一条消息,这意味着你的 JBOSS FUSE MANAGEMENT CONSOLE 创建连接以发送消息并在之后停止。
请注意,默认情况下,ActiveMQ 永远不会过期发送到 DLQ 的消息,如果您想将它们保留 7 天,您可以设置 <sharedDeadLetterStrategy expiration="604800000" processExpired="true" processNonPersistent="true" />
http://activemq.apache.org/advisory-message.html
http://activemq.apache.org/message-redelivery-and-dlq-handling.html