ACTIVEMQ of messages and dead-letter management (DLQ)

Source: Internet
Author: User
Tags ack mongodb postgresql redis rollback firewall


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


Alibaba Cloud Hot Products

Elastic Compute Service (ECS) Dedicated Host (DDH) ApsaraDB RDS for MySQL (RDS) ApsaraDB for PolarDB(PolarDB) AnalyticDB for PostgreSQL (ADB for PG)
AnalyticDB for MySQL(ADB for MySQL) Data Transmission Service (DTS) Server Load Balancer (SLB) Global Accelerator (GA) Cloud Enterprise Network (CEN)
Object Storage Service (OSS) Content Delivery Network (CDN) Short Message Service (SMS) Container Service for Kubernetes (ACK) Data Lake Analytics (DLA)

ApsaraDB for Redis (Redis)

ApsaraDB for MongoDB (MongoDB) NAT Gateway VPN Gateway Cloud Firewall
Anti-DDoS Web Application Firewall (WAF) Log Service DataWorks MaxCompute
Elastic MapReduce (EMR) Elasticsearch

Alibaba Cloud Free Trail

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.