This topic describes the default message retry mechanism of the Message Queue for RabbitMQ broker to help you understand the processing logic of a message that fails to be consumed and select an appropriate message processing policy.
Message retry mechanism
- If you do not enable message consumption on the consumer client, no message retry is triggered.
- If you enable message consumption on the consumer client, consumption failures trigger
message retries. If the consumer client does not acknowledge a message within 1 minute
after the message is sent, it is considered that a consumption failure occurred.
- If the consumer client acknowledges a message that is retried, the broker immediately stops retrying the message.
- The retry interval ranges from 10 to 1800 seconds.
- A message can be retried 16 times at the maximum. If a message still fails to be consumed
after it is retried 16 times, it is discarded or sent to a dead-letter exchange:
- If you do not configure a dead-letter exchange for the queue of the message, the message is discarded.
- If you configure a dead-letter exchange for the queue, the message is sent to the dead-letter exchange and then routed to a dead-letter queue based on the routing key and binding key. You can query and export messages from a dead-letter queue. For more information about how to configure a dead-letter exchange, see Dead-letter exchange.
Message retry interval
Map properties = new HashMap(); properties.put("x-retry-interval", 150); AMQP.Queue.DeclareOk queueDeclareOk = channel.queueDeclare(Producer.QueueName, true, false, false, properties);