Updated on 2026-01-07 GMT+08:00

Viewing RocketMQ Messages

RocketMQ messages can be queried by topic, message ID, or message key. You can check whether a message is sent and consumed, whether the message content is correct, and track the message using Message Query.

Message Deletion Mechanism

Regardless of whether they have been consumed, RocketMQ messages are retained for 48 hours and the upper limit is 720 hours by default. For details about how to modify the retention period, see Changing RocketMQ Message Retention Period. 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% (for v4.8.0) or 75% (for v5.x).
  • 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.
  • RocketMQ messages have been produced and consumed from a client. For details, see Accessing RocketMQ on a Client (Without SSL), Accessing RocketMQ on a Client (With SSL), or Accessing RocketMQ on the Console.
  • To query messages by message ID, you need the name of the topic 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 topic to which the message belongs and the message key.

    The message key is configured in 5. Message keys can be recorded in topic queries.

Query Modes

Table 1 compares three modes of query.

Table 1 Message query modes

Search By

Search With

Description

Topic

Topic and time range

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

Message ID

Topic and message ID

Based on a topic and message ID, you can accurately locate a message to obtain its attributes.

Message key

Topic and message key

The messages that contain specific keys can be queried by topic and message key.

Querying the Message Content

  1. Log in to the RocketMQ console.
  2. Click a RocketMQ instance name to go to the instance overview page.
  3. In the navigation pane, choose Instance > Message Query.
  4. Query messages in either of the following ways:

    • By topic: Select the topic to be queried from the Topic drop-down list and the queue to the queried from the Queue drop-down list (only for RocketMQ 4.8.0). 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.

  5. In the row that contains the desired message, click View Details to view the message content.

    The message details include the message size, message creation time, and 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.
    • Click Copy to copy the message content.

Related Document

  • To query messages by calling an API, see Querying Messages.
  • The trace information, sending status, and consumption result of messages can be viewed based on the query result. For details, see Viewing the Message Trace
  • If the consumption result is not Retrieved, you can resend the message to a specified online client to check whether the consumer can receive the message. For details, see Verifying RocketMQ Message Consumption.