Reviewed-by: Liudmila Denisova <ldenisov@noreply.gitea.eco.tsi-dev.otc-service.com> Co-authored-by: chenjunjie <chenjunjie@huawei.com> Co-committed-by: chenjunjie <chenjunjie@huawei.com>
18 KiB
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.
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.
The message key is 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 |
Description |
|---|---|---|
Group |
Group and time 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 |
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 |
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 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 Application > Distributed Message Service for RocketMQ to open the DMS for RocketMQ page. - Click a RocketMQ instance name to go to the instance overview 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.
- 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.
- 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.
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 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 Application > Distributed Message Service for RocketMQ to open the DMS for RocketMQ page. - Click a RocketMQ instance name to go to the instance overview 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 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 Application > Distributed Message Service for RocketMQ to open the DMS for RocketMQ page. - Click a RocketMQ instance name to go to the instance overview 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.