Skip to content

Commit

Permalink
Merge pull request #2952 from zhangjidi2016/develop
Browse files Browse the repository at this point in the history
[ISSUE #2556] The queryMsgTraceById command supports specifying the customerTraceTopic
  • Loading branch information
duhenglucky committed May 27, 2021
2 parents 8e05485 + 5515791 commit 5e99cdb
Showing 1 changed file with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ public Options buildCommandlineOptions(Options options) {
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;
}

Expand All @@ -63,18 +67,22 @@ public void execute(CommandLine commandLine, Options options, RPCHook rpcHook) t
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 {
defaultMQAdminExt.shutdown();
}
}

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) {
Expand Down

0 comments on commit 5e99cdb

Please sign in to comment.