All Products
Search
Document Center

ApsaraMQ for RocketMQ:OnsMessageGetByMsgId

Last Updated:Mar 03, 2024

Queries the information about a message by specifying the message ID and determines whether the message has been consumed.

Operation description

Note API operations provided by Alibaba Cloud are used to manage and query resources of Alibaba Cloud services. We recommend that you integrate these API operations only in management systems. Do not use these API operations in the core system of messaging services. Otherwise, system risks may occur.
  • If a message is not consumed as expected, you can call this operation to query the information about the message for troubleshooting.
  • This operation uses the exact match method to query 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. The queried information about a message includes the point in time when the message was sent, the broker on which the message is stored, and the attributes of the message such as the message key and tag.

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer.

Authorization information

The following table shows the authorization information corresponding to the API. The authorization information can be used in the Action policy element to grant a RAM user or RAM role the permissions to call this API operation. Description:

  • Operation: the value that you can use in the Action element to specify the operation on a resource.
  • Access level: the access level of each operation. The levels are read, write, and list.
  • Resource type: the type of the resource on which you can authorize the RAM user or the RAM role to perform the operation. Take note of the following items:
    • The required resource types are displayed in bold characters.
    • If the permissions cannot be granted at the resource level, All Resources is used in the Resource type column of the operation.
  • Condition Key: the condition key that is defined by the cloud service.
  • Associated operation: other operations that the RAM user or the RAM role must have permissions to perform to complete the operation. To complete the operation, the RAM user or the RAM role must have the permissions to perform the associated operations.
OperationAccess levelResource typeCondition keyAssociated operation
mq:QueryMessageRead
  • All Resources
    *
    none
none

Request parameters

ParameterTypeRequiredDescriptionExample
MsgIdstringYes

The ID of the message that you want to query.

1E0578FE110F18B4AAC235C05F2*****
TopicstringYes

The topic that contains the message you want to query.

test-mq_topic
InstanceIdstringYes

The ID of the instance to which the message you want to query belongs.

MQ_INST_111111111111_DOxxxxxx

Response parameters

ParameterTypeDescriptionExample
object
RequestIdstring

The ID of the request. This parameter is a common parameter. Each request has a unique ID. You can use this ID to troubleshoot issues.

A07E3902-B92E-44A6-B6C5-6AA111111****
Dataobject

The data returned.

StoreSizeinteger

The size of the message.

407
ReconsumeTimesinteger

The number of retries that were performed to send the message to consumers.

1
StoreTimestamplong

The timestamp that indicates when the ApsaraMQ for RocketMQ broker stored the message.

1570761026708
InstanceIdstring

The ID of the instance

MQ_INST_111111111111_DOxxxxxx
MsgIdstring

The ID of the message.

1E0578FE110F18B4AAC235C0C8460BA2
StoreHoststring

The ApsaraMQ for RocketMQ broker that stores the message.

11.220.***.***:10911
Topicstring

The topic to which the message belongs.

test-mq_topic
PropertyListobject []

The attributes of the message.

Valuestring

The value of the attribute.

TagA
Namestring

The name of the attribute. Valid values:

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

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

TAGS
BornTimestamplong

The timestamp that indicates when the message was produced.

1570761026630
BodyCRCinteger

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

914112295
BornHoststring

The producer instance that generated the message.

42.120.**.**:64646

Examples

Sample success responses

JSONformat

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

Error codes

For a list of error codes, visit the Service error codes.

Change history

Change timeSummary of changesOperation
No change history

View the information about a message in the console

You can also view the information about a message in the Message Queue for Apache RocketMQ console.**** For more information, see Query a message.