Commit 9202de3 1 parent 23cc24c commit 9202de3 Copy full SHA for 9202de3
File tree 2 files changed +17
-0
lines changed
client/src/main/java/org/apache/rocketmq/client
2 files changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -88,6 +88,8 @@ public class DefaultMQPullConsumer extends ClientConfig implements MQPullConsume
88
88
89
89
private int maxReconsumeTimes = 16 ;
90
90
91
+ private boolean enableRebalance = true ;
92
+
91
93
public DefaultMQPullConsumer () {
92
94
this (MixAll .DEFAULT_CONSUMER_GROUP , null );
93
95
}
@@ -468,4 +470,12 @@ public void setMaxReconsumeTimes(final int maxReconsumeTimes) {
468
470
public void persist (MessageQueue mq ) {
469
471
this .getOffsetStore ().persist (queueWithNamespace (mq ));
470
472
}
473
+
474
+ public boolean isEnableRebalance () {
475
+ return enableRebalance ;
476
+ }
477
+
478
+ public void setEnableRebalance (boolean enableRebalance ) {
479
+ this .enableRebalance = enableRebalance ;
480
+ }
471
481
}
Original file line number Diff line number Diff line change @@ -381,13 +381,20 @@ public Set<SubscriptionData> subscriptions() {
381
381
382
382
@ Override
383
383
public void doRebalance () {
384
+ if (!defaultMQPullConsumer .isEnableRebalance ()) {
385
+ return ;
386
+ }
384
387
if (this .rebalanceImpl != null ) {
385
388
this .rebalanceImpl .doRebalance (false );
386
389
}
387
390
}
388
391
389
392
@ Override
390
393
public boolean tryRebalance () {
394
+ if (!defaultMQPullConsumer .isEnableRebalance ()) {
395
+ return true ;
396
+ }
397
+
391
398
if (this .rebalanceImpl != null ) {
392
399
return this .rebalanceImpl .doRebalance (false );
393
400
}
You can’t perform that action at this time.
0 commit comments