You can call this operation to query the information of a message based on a specified message ID and to determine whether the message has been consumed. The queried information includes the sending time, the Message Queue for Apache RocketMQ broker that stores the message, and properties such as the key and tag of the message.

It is an exact search to query a message by message ID. The message ID is obtained from SendResult returned after the message was sent. Therefore, you must store each message sending result.

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer. OpenAPI Explorer dynamically generates the sample code of the operation for different SDKs.

Request parameters

Parameter Type Required Example Description
Action String Yes OnsMessageGetByMsgId

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

InstanceId String Yes MQ_INST_111111111111_DOxxxxxx

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

MsgId String Yes 1E0578FE110F18B4AAC235C05F2*****

The ID of the message that you want to query.

Topic String Yes test-mq_topic

The topic of the message that you want to query.

Response parameters

Parameter Type Example Description
Data Struct

The returned query results.

Body String SGVsbG8gTVEg5raT7oWf5p6D5ai05ayt55iv

The body of the message.

BodyCRC Integer 914112295

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

BornHost String 42.120.**. **:64646

The producer instance that produced the message.

BornTimestamp Long 1570761026630

The timestamp indicating when the message was produced.

InstanceId String MQ_INST_111111111111_DOxxxxxx

The ID of the Message Queue for Apache RocketMQ instance corresponding to the message.

MsgId String 1E0578FE110F18B4AAC235C0C8460BA2

The ID of the message.

PropertyList Array

A returned list of properties of the message.

MessageProperty
Name String TAGS

The property of the message. Valid values:

  • TRACE_ON: indicates whether any trace of the message exists.
  • KEYS: the key property of the message.
  • TAGS: the tag property of the message.
  • INSTANCE_ID: the ID of the Message Queue for Apache RocketMQ instance corresponding to the message.

For more information about the terms, see Terms.

Value String TagA

The value of the message property.

ReconsumeTimes Integer 1

The number of consumption retries of the message.

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

The Message Queue for Apache RocketMQ broker that stored the message.

StoreSize Integer 407

The size of the message.

StoreTimestamp Long 1570761026708

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

Topic String test-mq_topic

The topic of the message.

RequestId String A07E3902-B92E-44A6-B6C5-6AA1111111799

The ID of the request. This is a common parameter.

Examples

Sample requests

http(s)://[Endpoint]/? Action=OnsMessageGetByMsgId
&InstanceId=MQ_INST_111111111111_DOxxxxxx
&MsgId=1E0578FE110F18B4AAC235C05F2*****
&Topic=test-mq_topic
&<Common request parameters>

Sample success responses

XML format

<OnsMessageGetByMsgIdResponse>
  <Data>
        <MsgId>1E0578FE110F18B4AAC235C0C8460BA2</MsgId>
        <Body>SGVsbG8gTVEg5raT7oWf5p6D5ai05ayt55iv</Body>
        <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-6AA1111111799</RequestId>
</OnsMessageGetByMsgIdResponse>

JSON format

{
  "Data": {
    "MsgId": "1E0578FE110F18B4AAC235C0C8460BA2",
    "Body": "SGVsbG8gTVEg5raT7oWf5p6D5ai05ayt55iv",
    "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-6AA1111111799"
}

Error codes

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