未验证 提交 5e99cdbe 编写于 作者: H Heng Du 提交者: GitHub

Merge pull request #2952 from zhangjidi2016/develop

[ISSUE #2556] The queryMsgTraceById command supports specifying the customerTraceTopic
...@@ -44,6 +44,10 @@ public class QueryMsgTraceByIdSubCommand implements SubCommand { ...@@ -44,6 +44,10 @@ public class QueryMsgTraceByIdSubCommand implements SubCommand {
Option opt = new Option("i", "msgId", true, "Message Id"); Option opt = new Option("i", "msgId", true, "Message Id");
opt.setRequired(true); opt.setRequired(true);
options.addOption(opt); options.addOption(opt);
opt = new Option("t", "traceTopic", true, "The name value of message trace topic");
opt.setRequired(false);
options.addOption(opt);
return options; return options;
} }
...@@ -63,7 +67,11 @@ public class QueryMsgTraceByIdSubCommand implements SubCommand { ...@@ -63,7 +67,11 @@ public class QueryMsgTraceByIdSubCommand implements SubCommand {
defaultMQAdminExt.setInstanceName(Long.toString(System.currentTimeMillis())); defaultMQAdminExt.setInstanceName(Long.toString(System.currentTimeMillis()));
try { try {
final String msgId = commandLine.getOptionValue('i').trim(); 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) { } catch (Exception e) {
throw new SubCommandException(this.getClass().getSimpleName() + "command failed", e); throw new SubCommandException(this.getClass().getSimpleName() + "command failed", e);
} finally { } finally {
...@@ -71,10 +79,10 @@ public class QueryMsgTraceByIdSubCommand implements SubCommand { ...@@ -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 { throws MQClientException, InterruptedException {
admin.start(); 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<MessageExt> messageList = queryResult.getMessageList();
List<TraceView> traceViews = new ArrayList<>(); List<TraceView> traceViews = new ArrayList<>();
for (MessageExt message : messageList) { for (MessageExt message : messageList) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册