You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@rocketmq.apache.org by GitBox <gi...@apache.org> on 2021/12/14 01:46:09 UTC

[GitHub] [rocketmq] panzhi33 commented on a change in pull request #3639: [ISSUE #3624]fix DefaultMQPushConsumerTest.testPullMessage_ExceptionO…

panzhi33 commented on a change in pull request #3639:
URL: https://github.com/apache/rocketmq/pull/3639#discussion_r768254475



##########
File path: client/src/main/java/org/apache/rocketmq/client/producer/RequestFutureHolder.java
##########
@@ -74,14 +69,39 @@ public void scanExpiredRequest() {
         }
     }
 
-    private RequestFutureHolder() {
+    public synchronized void startScheduledTask() {
+        if (this.producerNum.incrementAndGet() == 1) {
+            this.getScheduledExecutorService().scheduleAtFixedRate(new Runnable() {
+                @Override
+                public void run() {
+                    try {
+                        RequestFutureHolder.getInstance().scanExpiredRequest();
+                    } catch (Throwable e) {
+                        log.error("scan RequestFutureTable exception", e);
+                    }
+                }
+            }, 1000 * 3, 1000, TimeUnit.MILLISECONDS);
+        }
+    }
+
+    public synchronized void shutdown() {
+        if (this.producerNum.decrementAndGet() == 0) {
+            this.getScheduledExecutorService().shutdown();

Review comment:
       ok




-- 
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@rocketmq.apache.org

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