You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@eventmesh.apache.org by "mxsm (via GitHub)" <gi...@apache.org> on 2023/02/24 16:06:41 UTC

[GitHub] [incubator-eventmesh] mxsm commented on a diff in pull request #3243: [ISSUE #3242]Refactor EventMeshProducer

mxsm commented on code in PR #3243:
URL: https://github.com/apache/incubator-eventmesh/pull/3243#discussion_r1117241179


##########
eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/producer/EventMeshProducer.java:
##########
@@ -83,32 +86,24 @@ public synchronized void init(EventMeshHTTPConfiguration eventMeshHttpConfigurat
         keyValue.put("eventMeshIDC", eventMeshHttpConfiguration.getEventMeshIDC());
         mqProducerWrapper = new MQProducerWrapper(eventMeshHttpConfiguration.getEventMeshConnectorPluginType());
         mqProducerWrapper.init(keyValue);
-        inited.compareAndSet(false, true);
         log.info("EventMeshProducer [{}] inited.............", producerGroupConfig.getGroupName());
     }
 
 
-    public synchronized void start() throws Exception {
-        if (started.get()) {
+    public void start() throws Exception {
+
+        if (!started.compareAndSet(false, true)) {
             return;
         }
-
         mqProducerWrapper.start();
-        started.compareAndSet(false, true);
         log.info("EventMeshProducer [{}] started.............", producerGroupConfig.getGroupName());
     }
 
-    public synchronized void shutdown() throws Exception {
-        if (!inited.get()) {
-            return;
-        }
-
-        if (!started.get()) {
+    public void shutdown() throws Exception {
+        if (!inited.compareAndSet(true, false && !started.compareAndSet(true, false))) {

Review Comment:
   @xwm1992  I will fix it and resubmit this pr later



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@eventmesh.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: dev-help@eventmesh.apache.org