Updated on 2025-07-28 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.

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

How to Query

Table 1 compares three modes of query.

Table 1 Message query modes

Search By

Search With

Search In

Description

Topic

Topic and time range

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

Exact mode

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

Message key

Topic and message key

Fuzzy mode

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

A message producer is advised to set a unique key for each message. This ensures that the number of messages with the same key are within 64. Otherwise, some messages may be missed.

Querying the Message Content

  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 > Message Query.
  6. 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.
      Figure 1 Querying messages by topic

    • 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.
      Figure 2 Querying messages by ID

    • 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.
      Figure 3 Querying messages by key

  7. 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.
    Figure 4 Viewing message details
    • 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.