Distributed Message Service RocketMQ

Querying Messages by Message Key

2024-07-08 08:49:10

API Introduction

Used to query messages by Message Key.

API Restrictions

None.

URl

GET https://[endpoint]/v2/message/queryByKey

Request Parameters

Request Parameters

Required or Not

Position

Parameter Type

Description

prodInstId

Yes

url

String

Instance   ID

topicName

Yes

url

String

Topic   Name

key

Yes

url

String

Used to query message KEY values

Response Parameter

Response Parameter

Parameter Type

Description

statusCode

String

The status code of the interface on   the system layer. Success: 800; failure: 900.

message

String

Status Description

returnObj

String

Return the object. The parameters   included in this parameter are described in the comments in Response   Examples.

Description of Return Value returnObj

Response Parameter

Parameter Type

Description

total

Int

Total

rows

List

List   of Messages

Description of Return Value rows

Response Parameter

Parameter Type

Description

queueId

Int

Queue   ID

storeSize

Int

Message   Size

queueOffset

Long

Queue   Offset

sysFlag

Int

System   Flag

bornTimestamp

Long

Generation Timestamp, in milliseconds.

bornHost

String

Generation Host

storeTimestamp

Long

Storage Timestamp, in milliseconds.

msgId

String

Message   ID

commitLogOffset

Long

Physical   Offset

bodyCRC

Int

Body   CRC

reconsumeTimes

Int

Number   of Retries

preparedTransactionOffset

Long

Transaction   Offset

properties

Map<String,   String>

KEYS:   message key

UNIQ_KEY: indicates the unique key

messageBody

String

Message   body

status

String

Consumption   Status:

TO_CONSUME:   Not consumed

CONSUMING:   Consuming

CONSUMED:   Consumed

 

Sample Request

GET https://[endpoint]/v2/message/ queryByKey?key=test_key&prodInstId=70687660456281088&groupName=group

Examples of a Successful Response

{

    "returnObj":{

        "total":1,

        "rows":[

            {

                "queueId":3,

                "storeSize":485,

                "queueOffset":7,

                "sysFlag":0,

                "bornTimestamp":1661857434591,

                "bornHost":"192.168.71.1:55492",

                "storeTimestamp":1661857434599,

                "storeHost":"192.168.71.188:8422",

                "msgId":"C0A847BC000020E600000000000045FE",

                "commitLogOffset":17918,

                "bodyCRC":979262990,

                "reconsumeTimes":0,

                "preparedTransactionOffset":0,

                "topic":"test",

                "properties":{

                    "KEYS":"test_key",

                    "UNIQ_KEY":"050562443C7018B4AAC2996FB3DE0000"

                },

                "messageBody":"D8SQN8VlDr1ZD4r4KVtse9Zczg5A9FA2nT7vu7LwLZ2w6oQnnXSmARpRJgHA8VJ6akEtHcm470kilKhE4pGgTKoXf5fF0kpzLc3ek01dafpJsdyZgFjmk18RtqPdk68LVNZ6p5FuE0c8qMxDBZzMv462KdJtJC1FBbbeuKoBVtHb7wYf79uY4uKKZOE9l1dkLaV0dS4gQSCCQVcRNswNNRbcVZGFP2iYcsxAqkeTENxqhUOEvQm4kIAbbWl4cK9gOMpUnchJSpEd48gv9gcHHB5FGY0umLtbcUGDM3aR8mfjDEeWAjm8g4o3dl7ptwakDKVIDDTe",

                "status":null

            }

        ]

    },

    "message":"success",

    "statusCode":800

}

Example of a Failed Response

{

    "returnObj": {},

    "message": "...",

    "statusCode": "900"

}


2L9NrY6zE88d