Updated on 2024-02-27 GMT+08:00

Message Consumption API

Function

This API is used to consume messages in a specified queue. Multiple messages can be consumed at the same time.

  • When there are only a few messages in a queue, the number of messages actually consumed at a time may be less than the message quantity specified in the consumption request. However, all messages in the queue will be eventually obtained by the message consumer after multiple rounds of consumption. If the returned message is an empty array, no message is consumed.
  • The endpoint is https://{rest_connect_address}:9292. You can query the value of rest_connect_address through a specified instance interface.

URI

GET /v1/topic/{topic_name}/group/{group_name}/messages?ack_wait={ack_wait}& time_wait={time_wait}&max_msgs={max_msgs}

Table 1 Parameter description

Parameter

Type

Mandatory

Description

topic_name

String

Yes

Topic name.

group_name

String

Yes

Consumer group name. The value can contain a maximum of 249 characters, including letters, digits, hyphens (-), and underscores (_).

ack_wait

Integer

No

Timeout duration that the API call can wait for message consumption acknowledgement. The client needs to submit the message consumption acknowledgement within the specified time. If the message consumption is not acknowledged within this period of time, the system displays a message, indicating that message consumption acknowledgement has timed out or the handler is invalid. In this case, the system determines that the message fails to be consumed by default.

Value range: 1–300s

Default value: 15s

time_wait

Integer

No

Amount of time that the API call can wait for a message to arrive in the empty queue before returning an empty response.

If a message is available during the wait period, the message consumption result is returned immediately. If no dead letter message is available until the wait period expires, an empty response will be returned after the wait period ends.

Value range: 1–30s

Default value: 3s

max_msgs

Integer

No

Number of consumable messages that can be obtained per time.

Value range: 1–10

Default value: 10

max_bytes

Integer

No

Maximum message load that can be consumed each time.

Value range: 1–2097152

Default value: 524288

Request

Request parameters

None.

Example request

None.

Response

Response parameters

Parameter

Type

Description

handler

String

Message handler.

message

Object

Message content.

Table 2 Parameter description of message

Parameter

Type

Description

content

String

Message body content, which is encrypted using Base64.

Example response

[
   {
     "handler": "NCMxMDAjMTgjMA==",
     "message": {
       "content": "ImhlbGxvIGh1YXdlaWNsb3VkLTIi"
     }
   }
]