Updated on 2025-07-28 GMT+08:00

Managing RocketMQ Dead Letters

When a message fails to be consumed and retried, RocketMQ does not discard it immediately, but forwards it to a specific dead letter queue. Messages in such a queue are dead letter messages. These messages can be redelivered and consumed again after faults are rectified. If they cannot be processed temporarily, they can be exported and saved in case of deletion after expiration.

Feature Description

Dead letter messages:

  • Cannot be consumed.
  • The validity period is the same as that of normal messages. The default value is 48h. When the retention exceeds the default 48h, the data is automatically deleted. To change the retention period, see Changing RocketMQ Message Retention Period.

Dead letter queues:

  • A dead letter queue corresponds to a consumer group instead of a single consumer instance.
  • RocketMQ does not create a dead letter queue for a consumer group without dead letter messages.
  • A dead letter queue contains all dead letter messages from a consumer group, regardless of the topic to which the messages belong.

Prerequisites

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

    Message ID is the MsgId returned after the message is produced, for example, the content returned in 6. Message IDs can be recorded in topic queries.

  • To query messages by message key, you need the name of the consumer group to which the message belongs and the message key.

    Message Key is the message key configured in 7. Message keys can be recorded in topic queries.

How to Query Dead Letter Messages

Table 1 compares three query modes.

Table 1 Dead letter message query modes

Search By

Search With

Search In

Description

Group

Group and time range

Range

Based on a consumer group and time range, you can obtain all the dead letter messages meeting the query criteria in batches. Due to the large number of messages, matching is more difficult.

Message ID

Group and message ID

Exact mode

Based on a consumer group and message ID, you can accurately locate a dead letter message to obtain its attributes.

Message key

Group and message key

Fuzzy mode

Dead letter messages that contain specific keys can be queried by consumer group and message key.

Querying Dead Letter Messages

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

    DMS for RocketMQ instances in different regions cannot communicate with each other over an intranet. Select a nearest location for low latency and fast access.

  3. Click and choose Middleware > 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 Instance > 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 Consumer Group drop-down list. For Stored, select a time period.
      Figure 1 Querying dead letter messages by group

    • By message ID: Select the name of the consumer group to be queried from the Consumer Group drop-down list, enter the message ID of the dead letter message to be queried, and click Search.
      Figure 2 Querying dead letter messages by message ID

    • By message key: Select the name of the consumer group to be queried from the Consumer Group drop-down list, enter the message key of the dead letter message to be queried, and click Search.
      Figure 3 Querying dead letter messages by message key

Resending a Dead Letter Message

Messages that cannot be properly processed (consumption exception or return failure) will be in dead letter queues. They can be redelivered to consumers in the dead letter queues on the console.

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

    DMS for RocketMQ instances in different regions cannot communicate with each other over an intranet. Select a nearest location for low latency and fast access.

  3. Click and choose Middleware > 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 Instance > Dead Letter Queues.
  6. Resend dead letter messages in either of the following ways:

    After a dead letter message is successfully resent, it still exists in the dead letter queue and will not be deleted. Do not retry resending a dead letter message to avoid repeated consumption.

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

Exporting Dead Letter Messages

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

    DMS for RocketMQ instances in different regions cannot communicate with each other over an intranet. Select a nearest location for low latency and fast access.

  3. Click and choose Middleware > 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 Instance > 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 2 describes the fields of an exported message.

    Table 2 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 verification.

    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.

Related Document

To redeliver dead letter messages and export them by calling an API, see Resending Dead Letter Messages and Exporting Dead Letter Messages.