lizhiboo commented on a change in pull request #2617:
URL: https://github.com/apache/rocketmq/pull/2617#discussion_r580705501



##########
File path: 
example/src/main/java/org/apache/rocketmq/example/benchmark/Producer.java
##########
@@ -198,10 +209,27 @@ public void run() {
                             } catch (InterruptedException ignored) {
                             }
                         }
+                        if (messageNum > 0 && ++num >= msgNumLimit) {
+                            break;
+                        }
                     }
                 }
             });
         }
+        try {
+            sendThreadPool.shutdown();
+            sendThreadPool.awaitTermination(Long.MAX_VALUE, TimeUnit.DAYS);
+            timer.cancel();
+            if (snapshotList.size() > 1) {
+                doPrintStats(snapshotList, statsBenchmark, true);
+            } else {
+                System.out.printf("[Complete] Send Total: %d Send Failed: %d 
Response Failed: %d%n",
+                    statsBenchmark.getSendRequestSuccessCount().get() + 
statsBenchmark.getSendRequestFailedCount().get(),
+                    statsBenchmark.getSendRequestFailedCount().get(), 
statsBenchmark.getReceiveResponseFailedCount().get());
+            }
+            producer.shutdown();
+        } catch (InterruptedException ignored) {

Review comment:
       In this case, benchmark only runs once, throw InterruptedException and 
print exception message maybe friendly to users.




----------------------------------------------------------------
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:
[email protected]


Reply via email to