nowinkeyy commented on code in PR #5887:
URL: https://github.com/apache/rocketmq/pull/5887#discussion_r1098215771


##########
store/src/main/java/org/apache/rocketmq/store/DefaultMessageStore.java:
##########
@@ -2743,6 +2852,269 @@ public String getServiceName() {
 
     }
 
+    class MainBatchDispatchRequestService extends ServiceThread {
+
+        private final ExecutorService batchDispatchRequestExecutor;
+
+        public MainBatchDispatchRequestService() {
+            batchDispatchRequestExecutor = new ThreadPoolExecutor(
+                    
DefaultMessageStore.this.getBrokerConfig().getBatchDispatchRequestThreadPoolNums(),
+                    
DefaultMessageStore.this.getBrokerConfig().getBatchDispatchRequestThreadPoolNums(),
+                    1000 * 60,
+                    TimeUnit.MICROSECONDS,
+                    new LinkedBlockingQueue<>(4096),
+                    new 
ThreadFactoryImpl("BatchDispatchRequestServiceThread_"),
+                    new RejectedExecutionHandler() {
+                        @Override
+                        public void rejectedExecution(Runnable r, 
ThreadPoolExecutor executor) {
+                            try {
+                                LOGGER.warn("Task {} is blocking put into the 
workQueue", r);
+                                executor.getQueue().put(r);
+                            } catch (InterruptedException e) {
+                                LOGGER.error("Task {} failed to put into the 
workQueue", r);
+                            }
+                        }
+                    });
+        }
+
+        private void pollBatchDispatchRequest() {
+            if (!batchDispatchRequestQueue.isEmpty()) {
+                BatchDispatchRequest task = batchDispatchRequestQueue.poll();
+                batchDispatchRequestExecutor.execute(() -> {
+                    ByteBuffer tmpByteBuffer = task.byteBuffer.duplicate();

Review Comment:
   The differences I think are: 
   1) good() has a deny reject CallerRunsPolicy, and the calling thread main is 
responsible for performing the overflowed task. Bad() does not have a reject 
policy, and overflowed tasks are discarded. 
   2) Exceptions thrown within the scope of try will be catch. Exceptions 
thrown outside the scope of the try are thrown to a higher level and interrupt 
the current program, and seem to cause Executor to create a new thread (the 
previous thread may have been destroyed)



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

Reply via email to