tencent cloud

Feedback

Query General Message

Last updated: 2024-01-17 17:49:23
    When sending a message from its origin at the producer to the TDMQ for RocketMQ server, and finally to the consumers, TDMQ for RocketMQ records the flow progress of the message and displays as a message trace in the console.
    The message trace records the full course of the message, from its origin at the producer to the TDMQ for RocketMQ server, and finally to the consumers. This includes details about each phase, such as time duration (accurate to the microsecond), execution results, producer IP, and consumer IP. If you use a client version 5.0 or later one for producing and consuming messages, there is no need to individually activate the trace switch on the client.
    If you use a client v4.x, you need to enable the message trace feature via the client. An example of specific setting is as follows:
    Producer settings
    Push consumer settings
    Pull consumer settings
    Spring Boot Starter Integration (version 2.2.2 and above)
    DefaultMQProducer producer = new DefaultMQProducer(namespace, groupName,
    // ACL permissions
    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);
    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);
    }
    }
    
    }

    Operation Scenarios

    When you need to investigate the following issues, you can utilize the message query features in the TDMQ for RocketMQ console. You can search for specific messages by time dimension, or by message ID or message key found in the logs, in order to view the message content, parameters, and trace.
    Observe the specific content and parameters of a given message.
    Examine the producer IP from which a message was dispatched, verify its successful transmission, and determine the precise timestamp of its arrival at the server.
    Inspect whether the message has been persistently stored.
    Investigate which consumers have ingested the message, ascertain the success of the consumption, and determine the exact moment at which the consumption was acknowledged.
    Conduct a performance analysis of the distributed system by scrutinizing the message processing latency of the message queue.

    Steps

    1. Log in to the RocketMQ console and click on Message Query in the left sidebar.
    2. On the message query page, after selecting the region, follow the instructions to input the query conditions.
    Time Range: Select the desired query time range, supporting the options of the most recent 100 messages (default choice displays the latest 100 messages in chronological order), the last 30 minutes, last 1 hour, last 6 hours, last 24 hours, last 3 days, or a customizable time range.
    Cluster: Select the cluster where the Topic you intend to query is located.
    Topic: Select the desired Topic.
    Query Method: The message query feature supports the following query methods.
    Query all: This method is suitable for querying all messages.
    By message ID: This is a precise and high-speed query method with an exact match.
    By message key: This method is a fuzzy query. It is suitable for a scenario where you have set a message key with no recorded message ID.
    3. Click Query. The list below will show all the results of the search, displayed by pages.
    
    
    
    4. Locate contents or parameters of the message you require to view. Click View Details in the operation column to access the basic information, content (message body), detailed parameters, and consumption status of the message.
    In the consumption status section, you can view the Group that consumed the message and the consumption status. In the operation column, you can also perform the following actions:
    Resend: This action sends the message to a specific client again. If the message has already been successfully consumed, resending it may lead to duplicated consumption.
    Exception Diagnosis: If consumption is abnormal, you can access the exception diagnosis information.
    
    
    
    5. Click View Message Trace in the operation column, or click Message Trace in the details page. You can view the message trace of the message (For detailed information, please refer to Overview of Message Trace Query Results).
    
    
    

    Verify consumption

    After querying a message, you can click Verify Consumption in the operation column to send the message to a specified client for verification. Using this feature may lead to message duplication.
    Note:
    The consumption verification feature is exclusively use to verify the normalcy of the client's consumption logic with no influence on the standard message receiving process. Consequently, information such as the status of message consumption remains unaltered post-verification.
    
    
    

    Export messages

    After querying a message, you can click Export Message in the operation column to export details such as the message body, message Tag, message Key, message production time and consumption attributes.
    
    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