Skip to content

Commit

Permalink
Use cooperative rebalance
Browse files Browse the repository at this point in the history
This should minimize disruptions on rebalance.

Issue: BB-441
  • Loading branch information
francoisferrand committed Oct 6, 2023
1 parent 58ef55b commit f00734a
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/BackbeatConsumer.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ class BackbeatConsumer extends EventEmitter {
'allow.auto.create.topics': true,
'statistics.interval.ms': 1000,
'rebalance_cb': this._onRebalance.bind(this),
'partition.assignment.strategy': 'cooperative-sticky',
};
const topicParams = {};
if (this._fromOffset !== undefined) {
Expand Down Expand Up @@ -496,7 +497,7 @@ class BackbeatConsumer extends EventEmitter {
this._log.debug('rdkafka.assign', { err, assignment });

try {
this._consumer.assign(assignment);
this._consumer.incrementalAssign(assignment);
} catch (e) {
// Ignore exceptions if we are not connected
const logger = this._consumer.isConnected() ? this._log.error : this._log.debug;
Expand All @@ -510,7 +511,7 @@ class BackbeatConsumer extends EventEmitter {
});

if (!this._processingQueue || this._processingQueue.length() + this._processingQueue.running() === 0) {
this._consumer.unassign();
this._consumer.incrementalUnassign(assignment);
return;
}

Expand All @@ -521,7 +522,7 @@ class BackbeatConsumer extends EventEmitter {
this._log.debug('processing queue drained, un-assigning');

try {
this._consumer.unassign();
this._consumer.incrementalUnassign(assignment);
} catch (e) {
// Ignore exceptions if we are not connected
const logger = this._consumer.isConnected() ? this._log.error : this._log.debug;
Expand Down

0 comments on commit f00734a

Please sign in to comment.