ApsaraMQ for RocketMQ is a key service for asynchronous decoupling in business built around distributed architectures. The trace data that is provided by ApsaraMQ for RocketMQ effectively connects the upstream and downstream applications of business. This helps you identify and troubleshoot exceptions. This topic describes scenarios in which message traces are applicable and trace parameters provided by ApsaraMQ for RocketMQ. This topic also describes how to view message traces.
Common scenarios
Critical data for messaging is defined as trace parameters in ApsaraMQ for RocketMQ. ApsaraMQ for RocketMQ provides the visualization feature that displays query and analysis results in charts. You can quickly obtain business status and identify exceptions by querying message traces.
The following describes typical scenarios in which message traces are used:
Scenario 1: Check whether a message is sent or consumed.
Scenario 2: Check whether scheduled or delayed messages are delivered at the scheduled time.
Scenario 3: Check whether transactional messages are committed or rolled back.
Scenario 4: Check the identity information and machine information of producers and consumers for troubleshooting.
Trace parameters
The following table describes trace parameters in ApsaraMQ for RocketMQ.
Category | Parameter | Description |
Producer | Producer Information | The ApsaraMQ for RocketMQ account or AccessKey ID that the producer used to send the message. |
Hostname | The hostname of the machine where the producer client resides. | |
Sent At | The time when the producer started to send the message. | |
Arrival At | The time when the message was stored in the ApsaraMQ for RocketMQ broker. | |
Sending Result | The result of message sending. Valid values:
| |
Basic message information | Message Type | |
Message ID | The globally unique identifier of the message. This identifier is automatically generated by ApsaraMQ for RocketMQ. | |
Topic | The name of the topic to which the message belongs. | |
Message Key | The message key. The key of a message is the business identifier set by the producer to uniquely identify the business logic. | |
Message Tag | The message tag. The tag is used to specify the consumption type of a message in a specific topic. | |
Ordered message | Message Group | The group to which the message belongs. The group to which an ordered message belongs is specified by the producer. Messages in the same group are processed in the first-in, first-out (FIFO) order. |
Transactional message | Check Callback Time | The callback time when the transaction status was checked for the half message. |
Committed At | The time when the transactional message was committed to the consumer by the broker. | |
Rolled back At | The time when the transactional message was rolled back. | |
Scheduled message | Preset Delay Time | The time when the message was scheduled to be sent. |
Consumer | Consumption Result | The consumption result of the message. Valid values:
|
Consumer Information | The ApsaraMQ for RocketMQ account or AccessKey ID that the consumer used to subscribe to the message. | |
Hostname | The hostname of the machine where the consumer client resides. | |
Ordered Delivery | Indicates whether ordered delivery was enabled for the consumer group to which the consumer belongs. | |
Delivery Time | The time when the ApsaraMQ for RocketMQ broker delivered the message to the consumer. | |
Response Time | The time when the ApsaraMQ for RocketMQ broker received the consumption result returned by the consumer. | |
Invisible Duration | The period of time during which the message sent by the simple consumer was invisible. For more information, see Retry policies for messages consumed in Simple mode. | |
Modify Invisible Duration | The time when the simple consumer called the ChangeInvisibleDuration operation. | |
Time of Entering Dead-letter Queue | The time when the message was delivered to the dead-letter queue if the message failed to be consumed. |
Limits
By default, the message trace feature is disabled on clients that use Apache RocketMQ 3.x or 4.x SDKs. For more information, see Overview. If you use such a client and want to query message traces in the ApsaraMQ for RocketMQ console, you must enable the message trace feature in the messaging code. The following items describe the detailed configurations in the messaging code:
Producer
producer.setAccessChannel(AccessChannel.CLOUD);
Consumer
consumer.setAccessChannel(AccessChannel.CLOUD);
Billing rules
For subscription and pay-as-you-go ApsaraMQ for RocketMQ instances, the message trace feature is enabled by default and free of charge.
For serverless ApsaraMQ for RocketMQ instances, you can manually enable or disable the message trace feature. For more information, see Enable or disable the message trace feature for a serverless instance.
If you enable the message trace feature for a serverless ApsaraMQ for RocketMQ instance, you are charged message trace fees based on the number of generated message traces. For more information, see Message trace fees.
Storage duration
For subscription and pay-as-you-go ApsaraMQ for RocketMQ instances, message traces can be retained for three days.
For serverless ApsaraMQ for RocketMQ instances, message traces can be retained for 14 days.
Query methods
ApsaraMQ for RocketMQ allows you to query message traces by using one of the following methods:
Query by message ID: This method is recommended for its exact matching and fast speed.
Query by message key: This method is a fuzzy query. If you use this method, you can query up to 1,000 message traces at a time. If you know the key of the message that you want to query but do not know the ID of the message, you can use this method.
Query by topic: This method is a range query. It is suitable for scenarios in which no message ID or message key is recorded and the number of messages is small. We recommend that you do not use this query method. In most cases, a large number of messages are produced in a topic within a specific time range. If you use this method, you can hardly identify a specific message among the queried messages.
Enable or disable the message trace feature for a serverless instance
After you disable the message trace feature for a serverless ApsaraMQ for RocketMQ instance, you cannot store or query the message traces of the instance, and the ApsaraMQ for RocketMQ console does not display the entry point for message traces.
After you enable the message trace feature for a serverless ApsaraMQ for RocketMQ instance, you are charged for message traces. For more information, see Message trace fees.
Log on to the ApsaraMQ for RocketMQ console. In the left-side navigation pane, click Instances.
In the top navigation bar, select a region, such as China (Hangzhou). On the Instances page, click the name of the instance that you want to manage.
On the Instance Details page, click the Basic Information tab. In the Message Trace card, click Enable or Disable.
In the message that appears, click OK.
Query a message trace
Log on to the ApsaraMQ for RocketMQ console. In the left-side navigation pane, click Instances.
In the top navigation bar, select a region, such as China (Hangzhou). On the Instances page, click the name of the instance that you want to manage.
In the left-side navigation pane, click Message Traces. On the Message Traces page, select a query method to create a query task.
View the trace details based on the query result.