Queries the information about a message based on the ID of the message.

Note

  • If a message is not consumed as expected, you can call this operation to query the information about the message for troubleshooting.
  • You can call this operation to query the information about a message based on the message ID. You can obtain the message ID from the SendResult parameter that is returned after the message is sent. You must store the returned information after each message is sent. This operation returns information such as the point in time when the message is published to the Message Queue for Apache RocketMQ broker, the information about the Message Queue for Apache RocketMQ server on which the message is stored, and properties such as the message keys and tags of the message.

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

OnsMessageGetByMsgId

mq:QueryInstanceBaseInfo

mq:QueryMessage

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

acs:mq:*:*:{topic}

Request parameters

Parameter Type Required Example Description
Action String Yes OnsMessageGetByMsgId

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

MsgId String Yes 1E0578FE110F18B4AAC235C05F2*****

The ID of the message that you want to query.

Topic String Yes test-mq_topic

The topic in which the message you want to query is stored.

InstanceId String Yes MQ_INST_111111111111_DOxxxxxx

The ID of the Message Queue for Apache RocketMQ instance which contains the message you want to query.

Note For more information about request parameters, see Common parameters and Make API requests.

Response parameters

Parameter Type Example Description
RequestId String A07E3902-B92E-44A6-B6C5-6AA111111****

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.

StoreSize Integer 407

The size of the message.

ReconsumeTimes Integer 1

The number of retries that the Message Queue for Apache RocketMQ broker performs to send the message to consumers.

StoreTimestamp Long 1570761026708

The timestamp when the Message Queue for Apache RocketMQ broker stored the message.

InstanceId String MQ_INST_111111111111_DOxxxxxx

The ID of the Message Queue for Apache RocketMQ instance which contains the message.

MsgId String 1E0578FE110F18B4AAC235C0C8460BA2

The ID of the message.

StoreHost String 11.220.***.***:10911

The Message Queue for Apache RocketMQ server that stores the message.

Topic String test-mq_topic

The topic in which the message is stored.

PropertyList Array of MessageProperty

The properties of the message.

MessageProperty
Value String TagA

The value of the property.

Name String TAGS

The name of the property. Valid values:

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

For more information about the terms that are used in Message Queue for Apache RocketMQ, see Terms.

BornTimestamp Long 1570761026630

The timestamp when the message was produced.

BodyCRC Integer 914112295

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

BornHost String 42.120.**.**:64646

The producer client that generated the message.

Examples

Sample requests

http(s)://ons.cn-hangzhou.aliyuncs.com/?Action=OnsMessageGetByMsgId
&InstanceId=MQ_INST_111111111111_DOxxxxxx
&MsgId=1E0578FE110F18B4AAC235C05F2*****
&Topic=test-mq_topic
&<Common request parameters>

Sample success responses

XML format

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

<OnsMessageGetByMsgIdResponse>
<Data>
    <MsgId>1E0578FE110F18B4AAC235C0C8460BA2</MsgId>
    <InstanceId>MQ_INST_111111111111_DOxxxxxx</InstanceId>
    <ReconsumeTimes>1</ReconsumeTimes>
    <BornHost>42.120.**.**:64646</BornHost>
    <BodyCRC>914112295</BodyCRC>
    <StoreHost>11.220.***.***:10911</StoreHost>
    <StoreTimestamp>1570761026708</StoreTimestamp>
    <BornTimestamp>1570761026630</BornTimestamp>
    <Topic>test-mq_topic</Topic>
    <StoreSize>407</StoreSize>
    <PropertyList>
        <MessageProperty>
            <Name>TAGS</Name>
            <Value>TagA</Value>
        </MessageProperty>
    </PropertyList>
</Data>
<RequestId>A07E3902-B92E-44A6-B6C5-6AA111111****</RequestId>
</OnsMessageGetByMsgIdResponse>

JSON format

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

{
  "Data" : {
    "MsgId" : "1E0578FE110F18B4AAC235C0C8460BA2",
    "InstanceId" : "MQ_INST_111111111111_DOxxxxxx",
    "ReconsumeTimes" : 1,
    "BornHost" : "42.120.**.**:64646",
    "BodyCRC" : 914112295,
    "StoreHost" : "11.220.***.***:10911",
    "StoreTimestamp" : 1570761026708,
    "BornTimestamp" : 1570761026630,
    "Topic" : "test-mq_topic",
    "StoreSize" : 407,
    "PropertyList" : {
      "MessageProperty" : [ {
        "Name" : "TAGS",
        "Value" : "TagA"
      } ]
    }
  },
  "RequestId" : "A07E3902-B92E-44A6-B6C5-6AA111111****"
}

Error codes

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

Query the information about a message in the console

In the Message Queue for Apache RocketMQ console, you can query the information about a message. For more information, see Query a message.