Querying a Message with a Specified Time Period
Function
This API is used to query a message with a specified time period.
Calling Method
For details, see Calling APIs.
URI
GET /v2/{project_id}/instances/{instance_id}/management/topics/{topic}/messages
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
project_id |
Yes |
String |
Definition: Project ID. For details, see Obtaining a Project ID. Constraints: N/A Range: N/A Default Value: N/A |
|
instance_id |
Yes |
String |
Definition: Instance ID. You can call the API for querying all instances to obtain the instance ID. The instance ID is in the response body. Constraints: N/A Range: N/A Default Value: N/A |
|
topic |
Yes |
String |
Definition: Topic name. Constraints: A topic name must start with a letter and can only contain letters, hyphens (-), underscores (_), and digits. Range: N/A Default Value: N/A |
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
start_time |
No |
String |
Definition: Query start time as a Unix timestamp. Constraints: N/A Range: N/A Default Value: 0 |
|
end_time |
No |
String |
Definition: Query end time as a Unix timestamp. Constraints: N/A Range: N/A Default Value: Current system time. |
|
limit |
No |
Integer |
Definition: Number of messages returned on a page. Constraints: N/A Range: N/A Default Value: 10 |
|
offset |
No |
Integer |
Definition: Offset, which is the position where the query starts. Constraints: N/A Range: ≥ 0 Default Value: N/A |
|
partition |
No |
String |
Definition: Partition ID. Constraints: N/A Range: N/A Default Value: The default value is -1, indicating that all partitions are queried. |
Request Parameters
None
Response Parameters
Status code: 200
|
Parameter |
Type |
Description |
|---|---|---|
|
messages |
Array of messages objects |
Definition: Message list. |
|
messages_count |
Integer |
Definition: Total number of messages. Range: N/A |
|
offsets_count |
Integer |
Definition: Total number of pages. Range: N/A |
|
offset |
Integer |
Definition: Current page number. Range: N/A |
|
Parameter |
Type |
Description |
|---|---|---|
|
topic |
String |
Definition: Topic name. Range: N/A |
|
partition |
Integer |
Definition: Partition ID. Range: N/A |
|
message_offset |
Long |
Definition: Message ID. Range: N/A |
|
size |
Integer |
Definition: Message size, in bytes. Range: N/A |
|
timestamp |
Long |
Definition: Message production time. The value is a Unix timestamp. The unit is millisecond. Range: N/A |
Example Requests
GET https://{endpoint}/v2/{project_id}/instances/{instance_id}/management/topics/{topic}/messages
Example Responses
Status code: 200
The message with the specified time period is queried successfully.
{
"messages" : [ {
"topic" : "mytest",
"partition" : 0,
"message_offset" : 7,
"size" : 6,
"timestamp" : 1568125036045
} ],
"messages_count" : 1,
"offsets_count" : 1,
"offset" : 1
}
Status Codes
|
Status Code |
Description |
|---|---|
|
200 |
The message with the specified time period is queried successfully. |
Error Codes
See Error Codes.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.