rocketmq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jinrongt...@apache.org
Subject [rocketmq] branch develop updated: [ISSUE #3361]DefaultMQProducer's constructor can call the overloaded constructor. (#3362)
Date Fri, 17 Sep 2021 11:46:06 GMT
This is an automated email from the ASF dual-hosted git repository.

jinrongtong 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 0de4038  [ISSUE #3361]DefaultMQProducer's constructor can call the overloaded constructor.
(#3362)
0de4038 is described below

commit 0de4038f8218eee122477c55d149133d706343ca
Author: zhangjidi2016 <1017543663@qq.com>
AuthorDate: Fri Sep 17 19:45:45 2021 +0800

    [ISSUE #3361]DefaultMQProducer's constructor can call the overloaded constructor. (#3362)
    
    Co-authored-by: zhangjidi <zhangjidi@cmss.chinamobile.com>
---
 .../rocketmq/client/producer/DefaultMQProducer.java | 21 +++------------------
 1 file changed, 3 insertions(+), 18 deletions(-)

diff --git a/client/src/main/java/org/apache/rocketmq/client/producer/DefaultMQProducer.java
b/client/src/main/java/org/apache/rocketmq/client/producer/DefaultMQProducer.java
index 0705935..50ca82b 100644
--- a/client/src/main/java/org/apache/rocketmq/client/producer/DefaultMQProducer.java
+++ b/client/src/main/java/org/apache/rocketmq/client/producer/DefaultMQProducer.java
@@ -158,22 +158,7 @@ public class DefaultMQProducer extends ClientConfig implements MQProducer
{
      */
     public DefaultMQProducer(final String producerGroup, RPCHook rpcHook, boolean enableMsgTrace,
         final String customizedTraceTopic) {
-        this.producerGroup = producerGroup;
-        defaultMQProducerImpl = new DefaultMQProducerImpl(this, rpcHook);
-        //if client open the message trace feature
-        if (enableMsgTrace) {
-            try {
-                AsyncTraceDispatcher dispatcher = new AsyncTraceDispatcher(producerGroup,
TraceDispatcher.Type.PRODUCE, customizedTraceTopic, rpcHook);
-                dispatcher.setHostProducer(this.defaultMQProducerImpl);
-                traceDispatcher = dispatcher;
-                this.defaultMQProducerImpl.registerSendMessageHook(
-                    new SendMessageTraceHookImpl(traceDispatcher));
-                this.defaultMQProducerImpl.registerEndTransactionHook(
-                    new EndTransactionTraceHookImpl(traceDispatcher));
-            } catch (Throwable e) {
-                log.error("system mqtrace hook init failed ,maybe can't send msg trace data");
-            }
-        }
+        this(null, producerGroup, rpcHook, enableMsgTrace, customizedTraceTopic);
     }
 
     /**
@@ -251,9 +236,9 @@ public class DefaultMQProducer extends ClientConfig implements MQProducer
{
         if (enableMsgTrace) {
             try {
                 AsyncTraceDispatcher dispatcher = new AsyncTraceDispatcher(producerGroup,
TraceDispatcher.Type.PRODUCE, customizedTraceTopic, rpcHook);
-                dispatcher.setHostProducer(this.getDefaultMQProducerImpl());
+                dispatcher.setHostProducer(this.defaultMQProducerImpl);
                 traceDispatcher = dispatcher;
-                this.getDefaultMQProducerImpl().registerSendMessageHook(
+                this.defaultMQProducerImpl.registerSendMessageHook(
                     new SendMessageTraceHookImpl(traceDispatcher));
                 this.defaultMQProducerImpl.registerEndTransactionHook(
                     new EndTransactionTraceHookImpl(traceDispatcher));

Mime
View raw message