未验证 提交 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 { ...@@ -68,14 +68,18 @@ public class SendMessageCommand implements SubCommand {
opt.setRequired(false); opt.setRequired(false);
options.addOption(opt); options.addOption(opt);
opt = new Option("m", "msgTraceEnable", true, "Message Trace Enable, Default: false");
opt.setRequired(false);
options.addOption(opt);
return options; return options;
} }
private DefaultMQProducer createProducer(RPCHook rpcHook) { private DefaultMQProducer createProducer(RPCHook rpcHook, boolean msgTraceEnable) {
if (this.producer != null) { if (this.producer != null) {
return producer; return producer;
} else { } else {
producer = new DefaultMQProducer(rpcHook); producer = new DefaultMQProducer(null, rpcHook, msgTraceEnable, null);
producer.setProducerGroup(Long.toString(System.currentTimeMillis())); producer.setProducerGroup(Long.toString(System.currentTimeMillis()));
return producer; return producer;
} }
...@@ -112,8 +116,11 @@ public class SendMessageCommand implements SubCommand { ...@@ -112,8 +116,11 @@ public class SendMessageCommand implements SubCommand {
} catch (Exception e) { } catch (Exception e) {
throw new RuntimeException(this.getClass().getSimpleName() + " command failed", e); throw new RuntimeException(this.getClass().getSimpleName() + " command failed", e);
} }
boolean msgTraceEnable = false;
DefaultMQProducer producer = this.createProducer(rpcHook); if (commandLine.hasOption('m')) {
msgTraceEnable = Boolean.parseBoolean(commandLine.getOptionValue('m').trim());
}
DefaultMQProducer producer = this.createProducer(rpcHook, msgTraceEnable);
SendResult result; SendResult result;
try { try {
producer.start(); producer.start();
...@@ -153,4 +160,4 @@ public class SendMessageCommand implements SubCommand { ...@@ -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.
先完成此消息的编辑!
想要评论请 注册