Unlocking RocketMQ: What Every SendResult Field Means
This article explains the composition of RocketMQ's SendResult object returned after a successful synchronous send, detailing each field such as sendStatus, msgId, offsetMsgId, messageQueue, and queueOffset, and provides practical examples and a full field‑by‑field breakdown for Java developers.
RocketMQ series article: "10‑minute RocketMQ: Java client practical guide (including detailed API)". The previous article covered usage of the RocketMQ Java client but left the question of which parameters are included in the return object after a successful send.
The result object of a successful synchronous send is SendResult. Below is an analysis of each field:
1 SendResult [
sendStatus=SEND_OK,
msgId=FDE6CE25AA470000185BBACBDC06F282647B18B4AAC2368769320000,
offsetMsgId=7925BA3A00002A9F0000000000000000,
messageQueue=MessageQueue [topic=pay-mini-pay-test, brokerName=broker-a, queueId=2],
queueOffset=0
]Field Details
Field
Meaning
Description
sendStatus
Sending status SEND_OK indicates the message was successfully stored in the broker.
msgId
Message ID
The globally unique ID generated for the message, used for tracing and troubleshooting.
offsetMsgId
Message physical offset
Represents the physical storage location of the message on the broker.
messageQueue
Message queue information
Indicates which topic, broker, and queue the message was sent to.
queueOffset
Queue offset
Shows the position (index) of the message within the queue.
Detailed Breakdown
1. sendStatus
SEND_OKmeans the message has been successfully stored in the broker.
Other possible statuses include: FLUSH_DISK_TIMEOUT: Disk flush timeout (may be due to synchronous flush configuration). FLUSH_SLAVE_TIMEOUT: Sync to slave timeout. SLAVE_NOT_AVAILABLE: Slave not available, cannot complete master‑slave sync.
2. msgId
The msgId is a globally unique ID generated by RocketMQ, for example:
FDE6CE25AA470000185BBACBDC06F282647B18B4AAC2368769320000It consists of the IP address (8 bytes), port (4 bytes), process ID (4 bytes), timestamp (8 bytes), and a sequence number (8 bytes).
3. offsetMsgId
Represents the physical offset address of the message in the broker.
Format includes Broker ID, Queue ID, and physical position.
4. messageQueue
Shows the queue information where the message is stored:
MessageQueue [topic=pay-mini-pay-test, brokerName=broker-a, queueId=2]Attribute
Explanation
Value
topic
Topic name pay-mini-pay-test brokerName
Broker name broker-a queueId
Queue ID 2 (the second queue on broker‑a)
5. queueOffset
Indicates the offset of the message within the queue (starting from 0).
Used by consumers to locate the message position.
Understanding SendResult is essential to truly grasp RocketMQ's message‑sending mechanism.
Lin is Dream
Sharing Java developer knowledge, practical articles, and continuous insights into computer engineering.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
