Updated on 2023-11-29 GMT+08:00

Managing Dead Letter Queues

Introduction

Dead letter queues store messages that cannot be correctly retrieved.

If a message fails to be retrieved, the system will retry sending it. After the maximum number of retries (which is 16 by default and configurable on the client) is reached and the message retrieval still fails, the message becomes a dead letter message and is delivered to the dead letter queue that corresponds to the consumer.

Dead letter messages:

  • Cannot be retrieved.
  • By default, dead letter messages are retained for 48 hours before being deleted automatically.

Scenario

This section describes how to query, export, and resend dead letter messages.

On the DMS for RocketMQ console, you can query dead letter messages by group, message ID, and message key.

  • By group: All dead letter messages of a specified consumer group within a specified period will be queried. This is range query and may find a large number of dead letter messages.
  • By message ID: The message with the specified message ID will be queried. This is exact search and can quickly find a specific dead letter message.
  • By message key: The message with the specified message key will be queried. This is exact search and can quickly find a specific dead letter message.

Prerequisites

  • A RocketMQ instance and consumer groups have been created.
  • To query by message ID, you need the name of the consumer group to which the message belongs and the message ID.
  • To query by message key, you need the name of the consumer group to which the message belongs and the message key.

Querying Dead Letter Messages

  1. Log in to the management console.
  2. Click in the upper left corner to select a region.

    Select the region where your RocketMQ instance is located.

  3. Click and choose Application > Distributed Message Service for RocketMQ to open the console of DMS for RocketMQ.
  4. Click a RocketMQ instance to go to the instance details page.
  5. In the navigation pane, choose Dead Letter Queues.
  6. Query dead letter messages in either of the following ways:

    • By group: Select the name of the consumer group to be queried from the Group drop-down list. For Stored, select a time period.
    • By message ID: Select the name of the consumer group to be queried from the Group drop-down list, enter the message ID of the dead letter message to be queried, and click Search.
    • By message key: Select the name of the consumer group to be queried from the Group drop-down list, enter the message key of the dead letter message to be queried, and click Search.

Exporting Dead Letter Messages

  1. Log in to the management console.
  2. Click in the upper left corner to select a region.

    Select the region where your RocketMQ instance is located.

  3. Click and choose Application > Distributed Message Service for RocketMQ to open the console of DMS for RocketMQ.
  4. Click a RocketMQ instance to go to the instance details page.
  5. In the navigation pane, choose Dead Letter Queues.
  6. Click Export Message in the row containing the desired message.

    The message will be exported in JSON format.

    To export multiple dead letter messages at a time, select them and click Export Message above the message list.

    Table 1 describes the fields of an exported message.

    Table 1 Message fields

    Parameter

    Description

    msg_id

    Message ID.

    instance_id

    Instance ID.

    topic

    Topic name.

    store_timestamp

    Time when the message is stored.

    born_timestamp

    Time when the message is generated.

    reconsume_times

    Number of retry times.

    body

    Message body.

    body_crc

    Message body checksum.

    store_size

    Storage size.

    property_list

    Message attribute list.

    • name: attribute name.
    • value: attribute value.

    born_host

    IP address of the host that generates the message.

    store_host

    IP address of the host that stores the message.

    queue_id

    Queue ID.

    queue_offset

    Offset in the queue.

Resending a Dead Letter Message

Dead letter messages cannot be retrieved by consumers. Locate and rectify the fault, and then resend dead letter messages on the console.

  1. Log in to the management console.
  2. Click in the upper left corner to select a region.

    Select the region where your RocketMQ instance is located.

  3. Click and choose Application > Distributed Message Service for RocketMQ to open the console of DMS for RocketMQ.
  4. Click a RocketMQ instance to go to the instance details page.
  5. In the navigation pane, choose Dead Letter Queues.
  6. Resend dead letter messages in either of the following ways:

    • In the row containing the dead letter message to be resent, click Resend.
    • Select multiple dead letter messages to be resent and click Resend.

    After a dead letter message is successfully resent, it still exists in the dead letter queue and will not be deleted. To avoid repeated retrieval, do not resend messages repeatedly.