All Products
Search
Document Center

ApsaraMQ for RocketMQ:OnsMessagePageQueryByTopic

Last Updated:Mar 03, 2024

Queries all messages that are stored in a specified topic within a specified time range by page.

Operation description

Note API operations provided by Alibaba Cloud are used to manage and query resources of Alibaba Cloud services. We recommend that you integrate these API operations only in management systems. Do not use these API operations in the core system of messaging services. Otherwise, system risks may occur.
  • If you do not know the ID or key of a message that you want to query, you can call this operation to query all messages that are stored in the topic within a specified time range. The results are displayed by page.

  • We recommend that you specify a short time range to query messages. If you specify a long time range, a large number of messages are returned. In this case, you cannot find the message that you want to query in an efficient manner. You can perform the following steps to query messages:

    1. Perform a paged query by specifying the topic, start time, end time, and number of entries to return on each page. If the topic contains messages, the information about the messages on the first page, total number of pages, and task ID are returned by default.
    2. Specify the task ID and a page number to call this operation again to query the messages on the specified page. The BeginTime, EndTime, and PageSize parameters do not take effect. By default, the system uses the values of these parameters that you specified in the request when you created the specified query task.

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer.

Authorization information

The following table shows the authorization information corresponding to the API. The authorization information can be used in the Action policy element to grant a RAM user or RAM role the permissions to call this API operation. Description:

  • Operation: the value that you can use in the Action element to specify the operation on a resource.
  • Access level: the access level of each operation. The levels are read, write, and list.
  • Resource type: the type of the resource on which you can authorize the RAM user or the RAM role to perform the operation. Take note of the following items:
    • The required resource types are displayed in bold characters.
    • If the permissions cannot be granted at the resource level, All Resources is used in the Resource type column of the operation.
  • Condition Key: the condition key that is defined by the cloud service.
  • Associated operation: other operations that the RAM user or the RAM role must have permissions to perform to complete the operation. To complete the operation, the RAM user or the RAM role must have the permissions to perform the associated operations.
OperationAccess levelResource typeCondition keyAssociated operation
mq:QueryMessageRead
  • All Resources
    *
    none
none

Request parameters

ParameterTypeRequiredDescriptionExample
TopicstringYes

The name of the topic whose messages you want to query.

test-mq_topic
BeginTimelongYes

The beginning of the time range to query. The value of this parameter is a UNIX timestamp in milliseconds. If you specify a valid value for the TaskId parameter in the request, this parameter does not take effect. The system uses the value of the BeginTime parameter that you specified in the request when you created the specified query task.

1570723200000
EndTimelongYes

The end of the time range to query. The value of this parameter is a UNIX timestamp in milliseconds. If you specify a valid value for the TaskId parameter in the request, this parameter does not take effect. The system uses the value of the EndTime parameter that you specified in the request when you created the specified query task.

1570809600000
TaskIdstringNo

The ID of the query task. The first time you call this operation to query the information about messages in a specified topic within a specified time range, this parameter is not required. This parameter is required in subsequent queries for messages on a specified page. You can obtain the task ID from the returned result of the first query.

0BC1310300002A9F000021E4D7A48346
CurrentPageintegerYes

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

2
PageSizeintegerNo

The number of entries to return on each page. Valid values: 5 to 50. Default value: 20. If you specify a valid value for the TaskId parameter in the request, this parameter does not take effect. The system uses the value of the PageSize parameter that you specified in the request for creating the query task.

5
InstanceIdstringYes

The ID of the instance to which the message you want to query belongs.

MQ_INST_111111111111_DOxxxxxx

Response parameters

ParameterTypeDescriptionExample
object

The data returned.

RequestIdstring

The ID of the request. This parameter is a common parameter. Each request has a unique ID. You can use this ID to troubleshoot issues.

5DC2A47E-2B31-4722-96C8-FA59C9*****
MsgFoundDoobject

The information about the message that is queried.

CurrentPagelong

The page number of the returned page.

1
MsgFoundListobject []

The information about messages on the returned page. The information that is contained in this parameter is the same as the information that is returned by the OnsMessageGetByMsgId operation.

StoreSizeinteger

The size of the message. Unit: KB.

406
ReconsumeTimesinteger

The number of retries that were performed to send the message to consumers.

1
StoreTimestamplong

The time when the ApsaraMQ for RocketMQ broker stored the message. The value is a UNIX timestamp that represents the number of milliseconds that have elapsed since the epoch time January 1, 1970, 00:00:00 UTC.

1570760999811
InstanceIdstring

The ID of the instance

MQ_INST_111111111111_DOxxxxxx
MsgIdstring

The ID of the message.

1E0578FE110F18B4AAC235C05F2*****
StoreHoststring

The ApsaraMQ for RocketMQ broker that stores the message.

11.193.***.***:10911
Topicstring

The topic to which the message belongs.

test-mq_topic
PropertyListobject []

The attributes of the message.

Valuestring

The value of the attribute.

TagA
Namestring

The name of the attribute. Valid values:

  • TRACE_ON: indicates whether a trace of the message exists.
  • KEYS: indicates the key of the message.
  • TAGS: indicates the tag of the message.
  • INSTANCE_ID: indicates the ID of the instance that contains the message.

For information about the terms that are used in ApsaraMQ for RocketMQ see Terms .

TAGS
BornTimestamplong

The time when the message was generated. The value is a UNIX timestamp that represents the number of milliseconds that have elapsed since the epoch time January 1, 1970, 00:00:00 UTC.

1570760999721
BodyCRCinteger

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

914112295
BornHoststring

The producer client that generated the message.

42.120.***.***:59270
MaxPageCountlong

The total number of returned pages.

400
TaskIdstring

The ID of the query task. The first time you call this operation to query the messages that are sent to a specified consumer group within a specified time range, this parameter is returned. You can use the task ID to query the details of messages on other returned pages.

0BC1310300002A9F000021E4D7A48346

Examples

Sample success responses

JSONformat

{
  "RequestId": "5DC2A47E-2B31-4722-96C8-FA59C9*****",
  "MsgFoundDo": {
    "CurrentPage": 1,
    "MsgFoundList": {
      "OnsRestMessageDo": [
        {
          "StoreSize": 406,
          "ReconsumeTimes": 1,
          "StoreTimestamp": 1570760999811,
          "InstanceId": "MQ_INST_111111111111_DOxxxxxx",
          "MsgId": "1E0578FE110F18B4AAC235C05F2*****",
          "StoreHost": "11.193.***.***:10911",
          "Topic": "test-mq_topic",
          "PropertyList": {
            "MessageProperty": [
              {
                "Value": "TagA",
                "Name": "TAGS"
              }
            ]
          },
          "BornTimestamp": 1570760999721,
          "BodyCRC": 914112295,
          "BornHost": "42.120.***.***:59270"
        }
      ]
    },
    "MaxPageCount": 400,
    "TaskId": "0BC1310300002A9F000021E4D7A48346"
  }
}

Error codes

For a list of error codes, visit the Service error codes.

Change history

Change timeSummary of changesOperation
No change history