You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@eventmesh.apache.org by GitBox <gi...@apache.org> on 2021/05/11 16:13:27 UTC

[GitHub] [incubator-eventmesh] jinrongluo opened a new pull request #343: [Issue #337] Enhance Http Demo Subscriber by using ExecutorService, CountDownLatch and PreDestroy hook

jinrongluo opened a new pull request #343:
URL: https://github.com/apache/incubator-eventmesh/pull/343


   Enhance Http Demo Subscriber by using ExecutorService, CountDownLatch and PreDestroy hook
   
   - Remove Thread.sleep()
   - Leveraging ExecutorService to manage the Thread lifecycle.
   - Leveraging PreDestroy annotation to manage the JVM Runtime Shutdown hook


-- 
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.

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


[GitHub] [incubator-eventmesh] jinrongluo commented on pull request #343: [Issue #337] Enhance Http Demo Subscriber by using ExecutorService, CountDownLatch and PreDestroy hook

Posted by GitBox <gi...@apache.org>.
jinrongluo commented on pull request #343:
URL: https://github.com/apache/incubator-eventmesh/pull/343#issuecomment-840082245


   hi @xwm1992 please review my latest commits and let me know if any questions. Thanks.


-- 
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.

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


[GitHub] [incubator-eventmesh] xwm1992 commented on a change in pull request #343: [Issue #337] Enhance Http Demo Subscriber by using ExecutorService, CountDownLatch and PreDestroy hook

Posted by GitBox <gi...@apache.org>.
xwm1992 commented on a change in pull request #343:
URL: https://github.com/apache/incubator-eventmesh/pull/343#discussion_r630698606



##########
File path: eventmesh-test/src/main/java/org/apache/eventmesh/http/demo/sub/controller/SubController.java
##########
@@ -33,12 +35,17 @@
 
     public static Logger logger = LoggerFactory.getLogger(SubController.class);
 
+    @Autowired
+    private SubService subService;
+
     @RequestMapping(value = "/test", method = RequestMethod.POST)
     public String subTest(@RequestBody String message) {
         logger.info("=======receive message======= {}", JSONObject.toJSONString(message));
         JSONObject result = new JSONObject();
         result.put("retCode", 1);
-        return result.toJSONString();
+        String strResult = result.toJSONString();
+        subService.consumeMessage(strResult);

Review comment:
       The semantics of the **47** code line looks like it should pass in the received message as a parameter, not the result of consumption




-- 
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.

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


[GitHub] [incubator-eventmesh] jinrongluo commented on a change in pull request #343: [Issue #337] Enhance Http Demo Subscriber by using ExecutorService, CountDownLatch and PreDestroy hook

Posted by GitBox <gi...@apache.org>.
jinrongluo commented on a change in pull request #343:
URL: https://github.com/apache/incubator-eventmesh/pull/343#discussion_r631006757



##########
File path: eventmesh-test/src/main/java/org/apache/eventmesh/http/demo/sub/service/SubService.java
##########
@@ -38,6 +44,11 @@
     final String dcn = "FT0";
     final String subsys = "1234";
 
+    // CountDownLatch size is the same as messageSize in AsyncPublishInstance.java (Publisher)
+    private CountDownLatch countDownLatch = new CountDownLatch(AsyncPublishInstance.messageSize);
+
+    private ExecutorService executorService = Executors.newFixedThreadPool(5);

Review comment:
       It is a best practice to use the JDK Concurrency library (ExecutorService + ThreadPool) to manage the lifecycle of Thread.
   
   Just suggestion. I can rollback to create Thread manually. Thanks for review comment.




-- 
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.

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


[GitHub] [incubator-eventmesh] jinrongluo commented on a change in pull request #343: [Issue #337] Enhance Http Demo Subscriber by using ExecutorService, CountDownLatch and PreDestroy hook

Posted by GitBox <gi...@apache.org>.
jinrongluo commented on a change in pull request #343:
URL: https://github.com/apache/incubator-eventmesh/pull/343#discussion_r631007708



##########
File path: eventmesh-test/src/main/java/org/apache/eventmesh/http/demo/sub/controller/SubController.java
##########
@@ -33,12 +35,17 @@
 
     public static Logger logger = LoggerFactory.getLogger(SubController.class);
 
+    @Autowired
+    private SubService subService;
+
     @RequestMapping(value = "/test", method = RequestMethod.POST)
     public String subTest(@RequestBody String message) {
         logger.info("=======receive message======= {}", JSONObject.toJSONString(message));
         JSONObject result = new JSONObject();
         result.put("retCode", 1);
-        return result.toJSONString();
+        String strResult = result.toJSONString();
+        subService.consumeMessage(strResult);

Review comment:
       Good comment! I will make the change to pass the message instead of result.




-- 
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.

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


[GitHub] [incubator-eventmesh] xwm1992 merged pull request #343: [Issue #337] Enhance Http Demo Subscriber by using ExecutorService, CountDownLatch and PreDestroy hook

Posted by GitBox <gi...@apache.org>.
xwm1992 merged pull request #343:
URL: https://github.com/apache/incubator-eventmesh/pull/343


   


-- 
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.

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


[GitHub] [incubator-eventmesh] xwm1992 commented on a change in pull request #343: [Issue #337] Enhance Http Demo Subscriber by using ExecutorService, CountDownLatch and PreDestroy hook

Posted by GitBox <gi...@apache.org>.
xwm1992 commented on a change in pull request #343:
URL: https://github.com/apache/incubator-eventmesh/pull/343#discussion_r630695370



##########
File path: eventmesh-test/src/main/java/org/apache/eventmesh/http/demo/sub/service/SubService.java
##########
@@ -38,6 +44,11 @@
     final String dcn = "FT0";
     final String subsys = "1234";
 
+    // CountDownLatch size is the same as messageSize in AsyncPublishInstance.java (Publisher)
+    private CountDownLatch countDownLatch = new CountDownLatch(AsyncPublishInstance.messageSize);
+
+    private ExecutorService executorService = Executors.newFixedThreadPool(5);

Review comment:
       Of cource it won't make a difference, but I wonder here is it necessary to use a thread pool?




-- 
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.

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


[GitHub] [incubator-eventmesh] xwm1992 commented on a change in pull request #343: [Issue #337] Enhance Http Demo Subscriber by using ExecutorService, CountDownLatch and PreDestroy hook

Posted by GitBox <gi...@apache.org>.
xwm1992 commented on a change in pull request #343:
URL: https://github.com/apache/incubator-eventmesh/pull/343#discussion_r630698606



##########
File path: eventmesh-test/src/main/java/org/apache/eventmesh/http/demo/sub/controller/SubController.java
##########
@@ -33,12 +35,17 @@
 
     public static Logger logger = LoggerFactory.getLogger(SubController.class);
 
+    @Autowired
+    private SubService subService;
+
     @RequestMapping(value = "/test", method = RequestMethod.POST)
     public String subTest(@RequestBody String message) {
         logger.info("=======receive message======= {}", JSONObject.toJSONString(message));
         JSONObject result = new JSONObject();
         result.put("retCode", 1);
-        return result.toJSONString();
+        String strResult = result.toJSONString();
+        subService.consumeMessage(strResult);

Review comment:
       The semantics of this line of code looks like it should pass in the received message as a parameter, not the result of consumption




-- 
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.

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