Queries the connection status of a consumer in a specified group.

Note

When messages are stacked in a topic, you can call this operation to check whether a consumer is online.

Request limit

Each Alibaba Cloud account can call this operation up to 10 times per second. If the number of requests that you send to call this operation within one second reaches the request limit, new requests fail. This may interrupt your business. For information about the request limit of each operation, see API request limits.

Authorization

By default, Alibaba Cloud accounts can call this operation. A Resource Access Management (RAM) user can call this operation only after the RAM user is granted the required permissions. The following table describes the permissions that must be granted to a RAM user to call this operation. For information about how to grant permissions, see Policies.

API

Action

Resource in an instance that uses a namespace

Resource in an instance that does not use a namespace

OnsConsumerGetConnection

mq:QueryInstanceBaseInfo

mq:QueryConsumerConnection

acs:mq:*:*:{instanceId}%{groupId}

acs:mq:*:*:{groupId}

Request parameters

Parameter Type Required Example Description
Action String Yes OnsConsumerGetConnection

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

GroupId String Yes GID_test_consumer_id

The ID of the consumer group to which the consumer you want to query belongs.

InstanceId String Yes MQ_INST_111111111111_DOxxxxxx

The ID of the consumer that you want to query.

Response parameters

Parameter Type Example Description
RequestId String DE4140C7-F42D-473D-A5FF-B1E31692****

The ID of the request. The system generates a unique ID for each request. You can troubleshoot issues based on the request ID.

Data Object

The data that is returned.

ConnectionList Array of ConnectionDo

The connection information that is returned.

ConnectionDo
Version String V4_3_6

The version of the consumer client.

ClientAddr String 30.5.121.**

The IP address and port number of the consumer.

Language String JAVA

The programming language in which the consumer application is developed.

ClientId String 30.5.121.**@24813#-1999745829#-1737591554#453111174894656

The ID of the consumer.

Examples

Sample requests

http(s)://ons.cn-hangzhou.aliyuncs.com/?Action=OnsConsumerGetConnection
&GroupId=GID_test_consumer_id
&InstanceId=MQ_INST_111111111111_DOxxxxxx
&<Common request parameters>

Sample success responses

XML format

HTTP/1.1 200 OK
Content-Type:application/xml

<OnsConsumerGetConnectionResponse>
    <Data>
        <ConnectionList>
            <ConnectionDo>
                <ClientAddr>30.5.121.**</ClientAddr>
                <Language>JAVA</Language>
                <Version>V4_3_6</Version>
                <ClientId>30.5.121.**@24813#-1999745829#-1737591554#453111174894656</ClientId>
            </ConnectionDo>
        </ConnectionList>
    </Data>
    <RequestId>DE4140C7-F42D-473D-A5FF-B1E31692****</RequestId>
</OnsConsumerGetConnectionResponse>

JSON format

HTTP/1.1 200 OK
Content-Type:application/json

{
  "Data" : {
    "ConnectionList" : {
      "ConnectionDo" : [ {
        "ClientAddr" : "30.5.121.**",
        "Language" : "JAVA",
        "Version" : "V4_3_6",
        "ClientId" : "30.5.121.**@24813#-1999745829#-1737591554#453111174894656"
      } ]
    }
  },
  "RequestId" : "DE4140C7-F42D-473D-A5FF-B1E31692****"
}

Error codes

For a list of error codes, visit the API Error Center.

View the connection status of consumers in the console

In the Message Queue for Apache RocketMQ console, you can view the connection status of each consumer in a consumer group. For more information, see View the status of consumers.