the dlq-badmail queue (Dead letter queue) is used to hold messages that have failed or expired processing.
The message is redelivered (re-sent) when the following occurs: A transacted session is used and rollback () is called (using a transaction session, and the rollback () method is called). A transacted session is closed before commits is called (a transaction session, the commit was called before closing). A session is the using Client_acknowledge and Session.recover () is called (using the Client_acknowledge sign mode in the session, and called the Session.recover () method).
When a message is redelivered over Maximumredeliveries (the default is 6 times, refer to the following link), the broker is sent a "Poison ack", which is considered a Poison pill (poison pill), The broker will then send this message to DLQ for subsequent processing.
The default dead-letter queue is ACTIVEMQ.DLQ, and if not specifically specified, the Badmail is sent to this queue.
The default persistent message expires and is sent to DLQ, and non-persistent messages are not sent to DLQ
You can adjust the dead-letter send policy through the configuration file (Activemq.xml).
1. Do not use the default dead-letter queue
The default dead-letter messages for all queues are sent to the same default dead-letter queue, which is not easy to administer. Modifications can be made by individualdeadletterstrategy or shareddeadletterstrategy policies. As follows:
<broker...>
<destinationPolicy>
<policyMap>
<policyEntries>
<!- Set all queues, use ' > ', otherwise queue name--
<policyentry queue= ">" >
<deadLetterStrategy>
<!--
Queueprefix: Set dead letter queue prefix
usequeueforqueuemessages: Set use queue to save Badmail, you can also set Usequeuefortopicmessages, use topic to save Badmail --<individualdeadletterstrategy queueprefix= "DLQ." usequeueforqueuemessages= "true"/>
</deadLetterStrategy>
</policyEntry>
</policyEntries>
</policymap >
</destinationPolicy> ...
</broker>
2. Non-persistent messages are saved to the dead letter queue
<policyentry queue= ">" >
<deadLetterStrategy>
<shareddeadletterstrategy Processnonpersistent= "true"/>
</deadLetterStrategy>
</policyEntry>
3. Expired messages are not saved to the dead letter queue
<policyentry queue= ">" >
<deadLetterStrategy>
<shareddeadletterstrategy processexpired= "False"/>
</deadLetterStrategy>
</policyEntry>
4. Persistent messages are not saved to the dead letter queue
Discard All Dead Letter
<beans><broker ...>
<plugins>
<discardingdlqbrokerplugin dropall= "true" Droptemporarytopics= "true" droptemporaryqueues= "true"/>
</plugins>
</broker>
</ Beans>
For the expired, can be controlled by the Processexpired property, for the redelivered of the failure of the message, need to through the plug-in to achieve the following:
<beans>
<broker ...>
<plugins>
<discardingdlqbrokerplugin droponly= "MY. EXAMPLE. Topic.29 MY. EXAMPLE. queue.87 "reportinterval="/>
</plugins>
</broker>
</beans>
Note that the destination name is separated by a space
The Reportinterval property was used to denote how frequently does we output how many messages we had dropped-use 0 to dis Able.
To filter discarded messages with regular expressions:
<beans>
<broker ...>
<plugins>
<discardingdlqbrokerplugin droponly= "MY. EXAMPLE. TOPIC. [0-9] {3} MY. EXAMPLE. QUEUE. [0-9] {3} "reportinterval="/>
</plugins>
</broker>
</beans>
5. Properties of dead-letter queue Messages
Messages in the dead-letter queue will add several attributes, such as the original Expiration Time (originalexpiration), the original Originaldeliverymode, etc.
Reference:
DLQ Handling Instructions: http://activemq.apache.org/message-redelivery-and-dlq-handling.html
Individualdeadletterstrategy Property Description: http://fusesource.com/docs/broker/5.3/configref/http.activemq.apache.or/ Element/individualdeadletterstr.html
Shareddeadletterstrategy Property Description: http://fusesource.com/docs/broker/5.3/configref/http.activemq.apache.or/ Element/shareddeadletterstrateg.html
Redelivery Property Description: http://activemq.apache.org/redelivery-policy.html