You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@rocketmq.apache.org by du...@apache.org on 2021/05/27 03:35:59 UTC

[rocketmq] branch develop updated: [ISSUE #2556] The queryMsgTraceById command supports specifying the customerTraceTopic

This is an automated email from the ASF dual-hosted git repository.

duhengforever pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/rocketmq.git


The following commit(s) were added to refs/heads/develop by this push:
     new 5515791  [ISSUE #2556] The queryMsgTraceById command supports specifying the customerTraceTopic
     new 5e99cdb  Merge pull request #2952 from zhangjidi2016/develop
5515791 is described below

commit 5515791f669250b481c2a8ad378daea19eae18c8
Author: zhangjidi2016 <10...@qq.com>
AuthorDate: Thu May 27 10:54:17 2021 +0800

    [ISSUE #2556] The queryMsgTraceById command supports specifying the customerTraceTopic
---
 .../tools/command/message/QueryMsgTraceByIdSubCommand.java | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/tools/src/main/java/org/apache/rocketmq/tools/command/message/QueryMsgTraceByIdSubCommand.java b/tools/src/main/java/org/apache/rocketmq/tools/command/message/QueryMsgTraceByIdSubCommand.java
index 7c2b51f..7382ff5 100644
--- a/tools/src/main/java/org/apache/rocketmq/tools/command/message/QueryMsgTraceByIdSubCommand.java
+++ b/tools/src/main/java/org/apache/rocketmq/tools/command/message/QueryMsgTraceByIdSubCommand.java
@@ -44,6 +44,10 @@ public class QueryMsgTraceByIdSubCommand implements SubCommand {
         Option opt = new Option("i", "msgId", true, "Message Id");
         opt.setRequired(true);
         options.addOption(opt);
+
+        opt = new Option("t", "traceTopic", true, "The name value of message trace topic");
+        opt.setRequired(false);
+        options.addOption(opt);
         return options;
     }
 
@@ -63,7 +67,11 @@ public class QueryMsgTraceByIdSubCommand implements SubCommand {
         defaultMQAdminExt.setInstanceName(Long.toString(System.currentTimeMillis()));
         try {
             final String msgId = commandLine.getOptionValue('i').trim();
-            this.queryTraceByMsgId(defaultMQAdminExt, msgId);
+            String traceTopic = TopicValidator.RMQ_SYS_TRACE_TOPIC;
+            if (commandLine.hasOption('t')) {
+                traceTopic = commandLine.getOptionValue('t').trim();
+            }
+            this.queryTraceByMsgId(defaultMQAdminExt, traceTopic, msgId);
         } catch (Exception e) {
             throw new SubCommandException(this.getClass().getSimpleName() + "command failed", e);
         } finally {
@@ -71,10 +79,10 @@ public class QueryMsgTraceByIdSubCommand implements SubCommand {
         }
     }
 
-    private void queryTraceByMsgId(final DefaultMQAdminExt admin, String msgId)
+    private void queryTraceByMsgId(final DefaultMQAdminExt admin, String traceTopic, String msgId)
         throws MQClientException, InterruptedException {
         admin.start();
-        QueryResult queryResult = admin.queryMessage(TopicValidator.RMQ_SYS_TRACE_TOPIC, msgId, 64, 0, System.currentTimeMillis());
+        QueryResult queryResult = admin.queryMessage(traceTopic, msgId, 64, 0, System.currentTimeMillis());
         List<MessageExt> messageList = queryResult.getMessageList();
         List<TraceView> traceViews = new ArrayList<>();
         for (MessageExt message : messageList) {