RabbitMQ messaging middleware technology succinctly and 17 advanced version of ten dead letter queue

Dead Letter Queue Introduction

This article is "RabbitMQ succinctly series" in the seventeenth: RabbitMQ messaging middleware succinctly and 17 advanced version of ten dead letter queue

Dead letter queue: DLX (dead-letter-exchange)

    When a message is not a consumer, the queue became a dead letter queue.

In RabbitMQ, the dead letter queue with respect to the exchange. RabbitMQ dead-letter queue:

DLX use, when the message becomes a dead letter queue (dead message), it can be re-publish to another exchange, the exchange is a dead letter queue DLX.

In RabbitMQ, how to become a dead letter of the message? The following situations:

1: message is rejected

    Message is rejected is divided into: basic.reject and basic.nack two kinds

When both cases and is provided requeeu = false. It is set to return to the queue to false

2: TTL expired messages

    In the previous article, we talked about the timeliness of TTL message. When the message exceeds the timeout case

3: the maximum queue length

    Similarly, in the last article, we talked about the maximum when sending a message, the message is set. When the data length of message transmission exceeds the set value, this situation has become a dead letter queue.

image1.png

Take a look at the dead-letter queue rabbitmq:

DLX is a normal exchange, the exchange and the general is no different, it can be specified on any queue, in fact, it is to set up a queue of property only;

When this has dead letter queue time, this will automatically RabbitMQ republish the message exchange to set up, and then be routed to another queue.

Can listen to the messages in the queue to do the appropriate treatment, this feature can make up rabbitmq3.0 previous features support immediate parameters.

image2.png

Dead letter queue settings:

: a dead letter queue and Queue exchange , and then bind (this is nonsense, this is any queue ) :

Exchange:dlx.exchange

Queue:dlx.queue

Routingkey:#

: Then we declare the normal switches, queue, bind, but we need to add a parameter to the queue. This parameter is: arguments The .put ( "the X--Dead-Letter-the Exchange", " DLX .exchange").

Description: arguments.put ( "x-dad-letter-exchange", "where is the received exchange their dead letter queue definition")

Thus the expiration message, to requeue, when the maximum length of the queue, the message can be routed directly to the dead letter queue!

The code here is not a screenshot has been posted on git.

This chapter summarizes:

image3.png




Guess you like

Origin blog.51cto.com/kaigejava/2426330