未验证 提交 57c166bc 编写于 作者: F francis lee 提交者: GitHub

Merge pull request #2991 from yuz10/develop4

[ISSUE #2990] Add message tracing switch in sendMessage command of mqadmin
......@@ -68,14 +68,18 @@ public class SendMessageCommand implements SubCommand {
opt.setRequired(false);
options.addOption(opt);
opt = new Option("m", "msgTraceEnable", true, "Message Trace Enable, Default: false");
opt.setRequired(false);
options.addOption(opt);
return options;
}
private DefaultMQProducer createProducer(RPCHook rpcHook) {
private DefaultMQProducer createProducer(RPCHook rpcHook, boolean msgTraceEnable) {
if (this.producer != null) {
return producer;
} else {
producer = new DefaultMQProducer(rpcHook);
producer = new DefaultMQProducer(null, rpcHook, msgTraceEnable, null);
producer.setProducerGroup(Long.toString(System.currentTimeMillis()));
return producer;
}
......@@ -112,8 +116,11 @@ public class SendMessageCommand implements SubCommand {
} catch (Exception e) {
throw new RuntimeException(this.getClass().getSimpleName() + " command failed", e);
}
DefaultMQProducer producer = this.createProducer(rpcHook);
boolean msgTraceEnable = false;
if (commandLine.hasOption('m')) {
msgTraceEnable = Boolean.parseBoolean(commandLine.getOptionValue('m').trim());
}
DefaultMQProducer producer = this.createProducer(rpcHook, msgTraceEnable);
SendResult result;
try {
producer.start();
......@@ -153,4 +160,4 @@ public class SendMessageCommand implements SubCommand {
);
}
}
}
\ No newline at end of file
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册