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.
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
- Log in to the console.
- 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.
- Click
and choose Middleware > Distributed Message Service for RocketMQ to open the console of DMS for RocketMQ.
- Click a RocketMQ instance to go to the instance details page.
- In the navigation pane, choose Instance > Dead Letter Queues.
- 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
- 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.
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.
- Log in to the console.
- 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.
- Click
and choose Middleware > Distributed Message Service for RocketMQ to open the console of DMS for RocketMQ.
- Click a RocketMQ instance to go to the instance details page.
- In the navigation pane, choose Instance > Dead Letter Queues.
- 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
- Log in to the console.
- 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.
- Click
and choose Middleware > Distributed Message Service for RocketMQ to open the console of DMS for RocketMQ.
- Click a RocketMQ instance to go to the instance details page.
- In the navigation pane, choose Instance > Dead Letter Queues.
- 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.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot