panzhi33 commented on a change in pull request #3639:
URL: https://github.com/apache/rocketmq/pull/3639#discussion_r768289937
##########
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]