tencent cloud

Feedback

Querying Message

Last updated: 2023-03-28 10:15:36
    TDMQ for RocketMQ records the complete flow of a message being sent from the producer to the TDMQ for RocketMQ server for consumption by the consumer, which is displayed as a message trace in the console. A message trace records the entire process of how a message flows, including the duration of each stage (accurate down to the microsecond), execution result, producer IP, and consumer IP.
    

    Overview

    You can use the message query feature in the TDMQ for RocketMQ console to view the content, parameters, and trace of a specific message by time or by the message ID/message key displayed in the log. With this feature, you can do the following:
    View the specific content and parameters of the message.
    View the producer IP from which a message was sent, whether it was sent successfully, and the exact time when it arrived at the server.
    View whether the message was persistently stored.
    View the consumers who consumed the message, whether it was consumed successfully, and the exact time when its consumption was acknowledged.
    View the message queue's message processing latency to analyze the performance of the distributed system.

    Query Limits

    You can query messages in the last 3 days.

    Prerequisites

    You have deployed the producer and consumer services as instructed in the SDK Documentation, and they have produced and consumed messages in the last three days.
    The TDMQ for RocketMQ virtual cluster service has been upgraded in some regions since August 8, 2022. The message trace feature of the old version of a virtual cluster is implemented by the server while that of the new version is implemented by the client. Therefore, if you use the new version of TDMQ for RocketMQ virtual cluster, you need to configure your client to enable the message trace feature. Below are sample settings:
    Producer settings
    Push consumer settings
    Pull consumer settings
    DefaultMQProducer producer = new DefaultMQProducer(namespace, groupName,
    // ACL permission
    new AclClientRPCHook(new SessionCredentials(AK, SK)), true, null);
    // Instantiate the consumer
    DefaultMQPushConsumer pushConsumer = new DefaultMQPushConsumer(NAMESPACE,groupName,
    new AclClientRPCHook(new SessionCredentials(AK, SK)),
    new AllocateMessageQueueAveragely(), true, null);
    DefaultLitePullConsumer pullConsumer = new DefaultLitePullConsumer(NAMESPACE,groupName,
    new AclClientRPCHook(new SessionCredentials(AK, SK)));
    // Set the NameServer address
    pullConsumer.setNamesrvAddr(NAMESERVER);
    pullConsumer.setConsumeFromWhere(ConsumeFromWhere.CONSUME_FROM_LAST_OFFSET);
    pullConsumer.setAutoCommit(false);
    pullConsumer.setEnableMsgTrace(true);
    pullConsumer.setCustomizedTraceTopic(null);
    If you use Spring Boot Starter 2.2.2 or later for access, see below for the specific code:
    package com.lazycece.sbac.rocketmq.messagemodel;
    
    import lombok.extern.slf4j.Slf4j;
    import org.apache.rocketmq.spring.annotation.MessageModel;
    import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
    import org.apache.rocketmq.spring.core.RocketMQListener;
    import org.springframework.stereotype.Component;
    
    /**
    * @author lazycece
    * @date 2019/8/21
    */
    @Slf4j
    @Component
    public class MessageModelConsumer {
    
    @Component
    @RocketMQMessageListener(
    topic = "topic-message-model",
    consumerGroup = "message-model-consumer-group",
    enableMsgTrace = true,
    messageModel = MessageModel.CLUSTERING)
    public class ConsumerOne implements RocketMQListener<String> {
    @Override
    public void onMessage(String message) {
    log.info("ConsumerOne: {}", message);
    }
    }
    
    }

    Directions

    1. Log in to the TDMQ for RocketMQ console and click Message Query on the left sidebar.
    2. On the Message Query page, select a region and enter the query conditions as prompted.
    Time Range: Select the time range for query. You can select the last 30 minutes, last hour, last 6 hours, last 24 hours, or last 3 days, or set a custom time range. By default, the last 100 messages are displayed in chronological order.
    Current Cluster: Select the cluster where the topic you want to query is located.
    Namespace: Select the namespace where the topic you want to query is located.
    Topic: Select the topic you want to query.
    Query Method: Below are two supported query methods.
    By message ID: A fast exact query method.
    By message key: A fuzzy query method that is used when you have only set the message key.
    3. Click Query, and the paginated results will be displayed in the list.
    
    4. Click View Details in the Operation column of the target message to view its basic information, content (message body), and parameters.
    In the Consumption Status module, you can view the consumer group that consumes this message and its consumption status. You can also perform the following operations in the Operation column:
    Send Again: You can send the message to another client you specify. If the message has been successfully consumed, this operation may lead to repeated message consumption.
    Exception Diagnosis: If an exception occurred during message consumption, you can view the exception diagnosis details.
    Notes:
    For the group in the broadcast consumption mode, if there is no online client under it, the information about consumption and diagnosis exceptions will not be displayed on the details page in the above figure; if you need to check the consumption status, you can go to the message trace page to view it .
    5. Click View Message Trace in the Operation column or select the Message Trace tab on the details page to view the trace of the message. For more information, see Message Trace Description.

    Consumption verification

    After a message is found, you can click Verify Consumption in the Operation column to send the message to the specified client for verification. This feature may lead to message repetition.
    Note
    Currently, the consumption verification feature is only available to exclusive clusters. It only verifies the client consumption logic to make sure it is normal without affecting message receiving. Therefore, the verification causes no changes in any message information such as message consumption status.

    Message export

    After querying a certain message, you can click Export in the operation column to view the message body, tag, key, production time, and consumption attributes.
    You can also batch select and export messages on the current page. After the messages are exported locally, you can process them as needed, such as copying the message body or sorting them by time.
    Contact Us

    Contact our sales team or business advisors to help your business.

    Technical Support

    Open a ticket if you're looking for further assistance. Our Ticket is 7x24 avaliable.

    7x24 Phone Support