You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@rocketmq.apache.org by hu...@apache.org on 2021/06/23 03:00:35 UTC

[rocketmq] branch develop updated: test(benchmark): support delay message test (#3010)

This is an automated email from the ASF dual-hosted git repository.

huzongtang pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/rocketmq.git


The following commit(s) were added to refs/heads/develop by this push:
     new 160c577  test(benchmark): support delay message test (#3010)
160c577 is described below

commit 160c5772fbdf02e55cdc67bc3b74bb9f9c4c644b
Author: 张旭 <ma...@gmail.com>
AuthorDate: Wed Jun 23 11:00:07 2021 +0800

    test(benchmark): support delay message test (#3010)
    
    Co-authored-by: zhangxu16 <zh...@xiaomi.com>
---
 .../org/apache/rocketmq/example/benchmark/Producer.java | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/example/src/main/java/org/apache/rocketmq/example/benchmark/Producer.java b/example/src/main/java/org/apache/rocketmq/example/benchmark/Producer.java
index 6975ab5..32d4b9f 100644
--- a/example/src/main/java/org/apache/rocketmq/example/benchmark/Producer.java
+++ b/example/src/main/java/org/apache/rocketmq/example/benchmark/Producer.java
@@ -61,9 +61,11 @@ public class Producer {
         final boolean msgTraceEnable = commandLine.hasOption('m') && Boolean.parseBoolean(commandLine.getOptionValue('m'));
         final boolean aclEnable = commandLine.hasOption('a') && Boolean.parseBoolean(commandLine.getOptionValue('a'));
         final long messageNum = commandLine.hasOption('q') ? Long.parseLong(commandLine.getOptionValue('q')) : 0;
+        final boolean delayEnable = commandLine.hasOption('d') && Boolean.parseBoolean(commandLine.getOptionValue('d'));
+        final int delayLevel = commandLine.hasOption('e') ? Integer.parseInt(commandLine.getOptionValue('e')) : 1;
 
-        System.out.printf("topic: %s threadCount: %d messageSize: %d keyEnable: %s propertySize: %d tagCount: %d traceEnable: %s aclEnable: %s messageQuantity: %d%n",
-            topic, threadCount, messageSize, keyEnable, propertySize, tagCount, msgTraceEnable, aclEnable, messageNum);
+        System.out.printf("topic: %s threadCount: %d messageSize: %d keyEnable: %s propertySize: %d tagCount: %d traceEnable: %s aclEnable: %s messageQuantity: %d%n delayEnable: %s%n delayLevel: %s%n",
+            topic, threadCount, messageSize, keyEnable, propertySize, tagCount, msgTraceEnable, aclEnable, messageNum, delayEnable, delayLevel);
 
         final InternalLogger log = ClientLogger.getLog();
 
@@ -147,6 +149,9 @@ public class Producer {
                             if (keyEnable) {
                                 msg.setKeys(String.valueOf(beginTimestamp / 1000));
                             }
+                            if (delayEnable) {
+                                msg.setDelayTimeLevel(delayLevel);
+                            }
                             if (tagCount > 0) {
                                 long sendSucCount = statsBenchmark.getReceiveResponseSuccessCount().get();
                                 msg.setTags(String.format("tag%d", sendSucCount % tagCount));
@@ -266,6 +271,14 @@ public class Producer {
         opt.setRequired(false);
         options.addOption(opt);
 
+        opt = new Option("d", "delayEnable", true, "Delay message Enable, Default: false");
+        opt.setRequired(false);
+        options.addOption(opt);
+
+        opt = new Option("e", "delayLevel", true, "Delay message level, Default: 1");
+        opt.setRequired(false);
+        options.addOption(opt);
+
         return options;
     }