Querying Messages
Scenario
This section describes how to view the content of a message and check whether the message is successfully created or retrieved.
On the DMS for RocketMQ console, you can query messages by topic, message ID, or message key.
- By topic: All messages of a specified topic within a specified period will be queried. This is range query and may find a large number of messages.
- By message ID: The message with the specified message ID will be queried. This is exact search and can quickly find a specific message.
- By message key: The message with the specified message key will be queried. This is exact search and can quickly find a specific message.
Message Deletion Mechanism
By default, RocketMQ messages are retained for 48 hours (not modifiable), regardless of whether they have been consumed. RocketMQ messages are stored in CommitLog files. Each CommitLog file is 1 GB. When a CommitLog file is full, a new CommitLog file is generated. Message deletion in RocketMQ means to delete the CommitLog files, instead of individual messages. CommitLog files are written in sequence. A CommitLog file expires when the last message written in it expires. CommitLog files are deleted in the following scenarios:
- Expired files are cleared at 04:00 every day. Earlier instances that do not have a time zone are cleared at 12:00 every day.
- Expired files are deleted immediately when the disk usage reaches 70%.
- The earliest files are deleted, regardless of whether they have expired, when the disk usage reaches 85%.
Prerequisites
- A RocketMQ instance and topics have been created.
- To query messages by message ID, you need the name of the topic to which the message belongs and the message ID.
- To query messages by message key, you need the name of the topic to which the message belongs and the message key.
- To query message traces, you must first enable message tracing.
Querying the Message Content
- Log in to the management console.
- Click in the upper left corner to select a region.
Select the region where your RocketMQ instance is located.
- Click and choose Application > 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 Message Query.
- Query messages in either of the following ways:
- By topic: Select the name of the topic and the queue to be queried from the Topic and Queue drop-down lists. For Stored, select a time period.
- By message ID: Select the name of the topic to be queried from the Topic drop-down list, enter the ID of the message to be queried, and click Search.
- By message key: Select the name of the topic to be queried from the Topic drop-down list, enter the key of the message to be queried, and click Search.
- In the row that contains the desired message, click View Details to view the message content.
If the message body is greater than 4096 bytes, some content may not be displayed on the console. In this case, click Download to view the message body in the downloaded JSON file.
Viewing the Message Trace
- Log in to the management console.
- Click in the upper left corner to select a region.
Select the region where your RocketMQ instance is located.
- Click and choose Application > 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 Message Query.
- Query messages in either of the following ways:
- By topic: Select the name of the topic and the queue to be queried from the Topic and Queue drop-down lists. For Stored, select a time period.
- By message ID: Select the name of the topic to be queried from the Topic drop-down list, enter the ID of the message to be queried, and click Search.
- By message key: Select the name of the topic to be queried from the Topic drop-down list, enter the key of the message to be queried, and click Search.
- In the row that contains the desired message, click View Trace to check whether the message has been created or retrieved successfully.
Table 1 describes message trace parameters.
Table 1 Message trace parameters Parameter
Description
Producer status
A producer can be in one of the following states:
- Sent: The message is sent successfully, and the server has successfully stored the message.
- Committed: The message can be retrieved by consumers.
- Rollback: The message will be discarded and cannot be retrieved by consumers.
- Unknown: The status of the message cannot be determined. After a period of time, the server initiates a check request to the producer.
Creation duration
Time taken to send the message by the producer.
Producer address
IP address and port of the producer.
Consumer status
A consumer can be in one of the following states:
- Retrieved
- Retrieval timed out
- Abnormal retrieval
- NULL returned
- Retrieval failed
Retrieved
Time when the message is retrieved.
Retrieval duration
Time taken to retrieve the message by the consumer.
Consumer address
IP address and port of the consumer.
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