You can call this operation to query all messages of a specified topic within a specified time range by page.

It is a range search to query messages by topic name. Query results are displayed to the caller by page. This operation is only applicable to scenarios where no message ID and message key are available. We recommend that you shorten the query time range. Otherwise, it will be difficult to locate problems due to the excessive matched messages.

The procedure for calling this operation is as follows:

1. Specify the topic name, start time, end time, and number of entries on each page to return. If messages are available, the messages on the first page, total number of pages, and query task ID are returned by default.

2. Obtain messages by specifying the returned query task ID and the current page number.


OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer. OpenAPI Explorer dynamically generates the sample code of the operation for different SDKs.

Request parameters

Parameter Type Required Example Description
Action String Yes OnsMessagePageQueryByTopic

The operation that you want to perform. Set the value to OnsMessagePageQueryByTopic.

BeginTime Long Yes 1570723200000

The beginning of the time range to query.

CurrentPage Integer Yes 2

The number of the page to return. Pages start from page 1. Valid values: 1 to 50.

EndTime Long Yes 1570809600000

The end of the time range to query.

InstanceId String Yes MQ_INST_111111111111_DOxxxxxx

The ID of the Message Queue for Apache RocketMQ instance corresponding to the messages that you want to query.

Topic String Yes test-mq_topic

The topic of the messages that you want to query.

TaskId String No 0BC1310300002A9F000021E4D7A48346

The ID of the query task. It is not required for the first query but is required when you obtain messages subsequently. It can be obtained based on the previously returned result.

PageSize Integer No 5

The number of entries to return on each page. Valid values: 5 to 50. Default value: 20.

Response parameters

Parameter Type Example Description
MsgFoundDo Struct

The returned query results.

CurrentPage Long 1

The page number of the returned page.

MaxPageCount Long 400

The maximum number of returned pages.

MsgFoundList Array

A returned set of messages displayed on the current page. The results are the same as those returned for the OnsMessageGetByMsgId operation.

Body String SGVsbG8gTVEg5raT7oWf5p6D5ai05ayt55iv

The body of the message.

BodyCRC Integer 914112295

The cyclic redundancy check (CRC) value of the message body.

BornHost String 42.120.***. ***:59270

The producer instance that produced the message.

BornTimestamp Long 1570760999721

The timestamp indicating when the message was produced.

InstanceId String MQ_INST_111111111111_DOxxxxxx

The ID of the Message Queue for Apache RocketMQ instance corresponding to the message.

MsgId String 1E0578FE110F18B4AAC235C05F2*****

The ID of the message.

PropertyList Array

The returned properties of the message.

Name String TAGS

The property of the message. Valid values:

  • TRACE_ON: indicates whether any trace of the message exists.
  • KEYS: the key property of the message.
  • TAGS: the tag property of the message.
  • INSTANCE_ID: the ID of the Message Queue for Apache RocketMQ instance corresponding to the message.

For more information about the terms, see Terms.

Value String TagA

The value of the message property.

ReconsumeTimes Integer 1

The number of consumption retries of the message.

StoreHost String 11.193.***. ***:10911

The Message Queue for Apache RocketMQ broker that stored the message.

StoreSize Integer 406

The size of the message.

StoreTimestamp Long 1570760999811

The timestamp indicating when the Message Queue for Apache RocketMQ broker stored the message.

Topic String test-mq_topic

The topic of the message.

TaskId String 0BC1310300002A9F000021E4D7A48346

The task ID returned for the first query task, which is used to obtain messages subsequently.

RequestId String 5DC2A47E-2B31-4722-96C8-FA59C9*****

The ID of the request. This is a common parameter.


Sample requests

http(s)://[Endpoint]/? Action=OnsMessagePageQueryByTopic
&<Common request parameters>

Sample success responses

XML format

                            <BornHost>42.120. ***. ***:59270</BornHost>
                            <StoreHost>11.193. ***. ***:10911</StoreHost>

JSON format

  "MsgFoundDo": {
    "MaxPageCount": 400,
    "MsgFoundList": {
      "OnsRestMessageDo": [
          "MsgId": "1E0578FE110F18B4AAC235C05F2*****",
          "Body": "SGVsbG8gTVEg5raT7oWf5p6D5ai05ayt55iv",
          "InstanceId": "MQ_INST_111111111111_DOxxxxxx",
          "ReconsumeTimes": 1,
          "BornHost": "42.120. ***. ***:59270",
          "StoreTimestamp": 1570760999811,
          "StoreHost": "11.193. ***. ***:10911",
          "BodyCRC": 914112295,
          "Topic": "test-mq_topic",
          "BornTimestamp": 1570760999721,
          "StoreSize": 406,
          "PropertyList": {
            "MessageProperty": [
                "Name": "TAGS",
                "Value": "TagA"
    "TaskId": "0BC1310300002A9F000021E4D7A48346",
    "CurrentPage": 1