Queries all messages that are stored in a specified topic within a specified time range by page.
Operation description
-
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:
- 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.
- 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
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.
Operation | Access level | Resource type | Condition key | Associated operation |
---|---|---|---|---|
mq:QueryMessage | Read |
|
| none |
Request parameters
Parameter | Type | Required | Description | Example |
---|---|---|---|---|
Topic | string | Yes | The name of the topic whose messages you want to query. | test-mq_topic |
BeginTime | long | Yes | 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 |
EndTime | long | Yes | 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 |
TaskId | string | No | 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 |
CurrentPage | integer | Yes | The number of the page to return. Pages start from page 1. Valid values: 1 to 50. | 2 |
PageSize | integer | No | 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 |
InstanceId | string | Yes | The ID of the instance to which the message you want to query belongs. | MQ_INST_111111111111_DOxxxxxx |
Response parameters
Examples
Sample success responses
JSON
format
{
"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 time | Summary of changes | Operation |
---|