This topic introduces the mechanism, application scenarios, and use cases of MQ message tracing.
Note: MQ supports message tracing under TCP protocol currently.
Definition: Message trace is the complete route information of a message from its issuance by the producer to its consumption by a consumer, consisting of the time, location and other information on every node.
Mechanism: In the MQ system, the complete route information of a message involves three roles, i.e., the producer, the service provider, and the consumer. Each role inputs relevant information to the tracing when it processes the message. This information will be gathered to reflect the message’s current status, providing strong data support for troubleshooting in production environments.
Message trace includes:
|Producer information||Consumer information||Service information|
|Producer client information||Consumer client information||Message’s topic|
|Sending time||Delivery time and delivery round||The region where the message is stored|
|Sent successfully or not||Consumed successfully or not||Message key|
|Sending duration||Consumption duration||Message tag|
Message tracing rules:
|Message type||Time for query||Query description|
|Normal message||After the message is sent||Sending trace is generated once the message is sent. If the message is not consumed yet, “Not Consumed” is displayed, and once it is consumed, the delivery and consumption information is displayed.|
|Ordered message||After the message is sent||Sending trace is generated once the message is sent. If the message is not consumed yet, “Not Consumed” is displayed, and once it is consumed, the delivery and consumption information is displayed.|
|Scheduled/Delayed message||After the current system time reaches the specified message consuming time||If the current system time does not reach the specified message consuming time, the trace cannot be displayed while the message cannot.|
|Transactional message||After the message is sent||Sending trace is generated once the message is sent. Before the transaction is committed, the trace can be queried, but the message cannot.|
You can use the message tracing tool for troubleshooting when messages are not sent and received as expected in the production environment. Query a message’s trace by the its properties (message ID, message key, and topic) to check the sending and receiving status of the message, and in the end help diagnose the problem.
Suppose you find out that you have not received a message as expected based on the log information, then please follow the steps below to use message tracing to troubleshoot the issue.
Collect the information about the message that you suspect went wrong, including the message ID, message key, topic, and approximate sending time.
Log on to the MQ console, and create a query job based on the collected information to query the message trace.
Check the result, and analyze the cause. If the trace shows that the message has not been consumed, you can go to the Consumers page to check whether there are any messages accumulated, which may cause the issue.
If the message has been consumed, find the corresponding client and the message delivery time displayed in the consumption information, and log on to the client to view the log.