Skip to content

Commit 41b2976

Browse files
committed
Speed up rocketmq-scenario rebalance by tuning waitInterval from 20s to 2s
Reduces the healthCheck timer gate from 30s to 8s accordingly.
1 parent 3e7e1a8 commit 41b2976

File tree

1 file changed

+8
-4
lines changed
  • test/plugin/scenarios/rocketmq-scenario/src/main/java/test/apache/skywalking/apm/testcase/rocketmq/controller

1 file changed

+8
-4
lines changed

test/plugin/scenarios/rocketmq-scenario/src/main/java/test/apache/skywalking/apm/testcase/rocketmq/controller/CaseController.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,13 @@ public String healthCheck() throws Exception {
8282
// take longer than that).
8383
consumerStarted = true;
8484
try {
85+
// Speed up client-side rebalance from default 20s to 2s so the
86+
// consumer discovers topic queues faster after startup.
87+
System.setProperty("rocketmq.client.rebalance.waitInterval", "2000");
88+
8589
// Send a probe message to ensure the topic exists before consumer starts.
8690
// Without this, the consumer's rebalance finds no queues and it would need
87-
// another full rebalance cycle (~20s) after the topic is eventually created.
91+
// another full rebalance cycle after the topic is eventually created.
8892
DefaultMQProducer probeProducer = new DefaultMQProducer("healthCheck_please_rename_unique_group_name");
8993
probeProducer.setNamesrvAddr(namerServer);
9094
probeProducer.start();
@@ -115,9 +119,9 @@ public ConsumeConcurrentlyStatus consumeMessage(List<MessageExt> msgs, ConsumeCo
115119
}
116120

117121
// PushConsumer needs time for initial rebalance with the broker.
118-
// Return non-200 to force health check retries (3s each), giving
119-
// the consumer enough time before the entry service is called.
120-
if (System.currentTimeMillis() - consumerStartTime < 30000) {
122+
// With rebalance interval tuned to 2s (default 20s), 8s is enough.
123+
// Return non-200 to force health check retries (3s each).
124+
if (System.currentTimeMillis() - consumerStartTime < 8000) {
121125
throw new RuntimeException("Consumer rebalance in progress");
122126
}
123127

0 commit comments

Comments
 (0)