Skip to content

Commit

Permalink
Each worker has it own consumer group
Browse files Browse the repository at this point in the history
  • Loading branch information
NV4RE committed Sep 8, 2020
1 parent 577abbe commit d0c5aa6
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/syncWorker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,21 @@ export class SyncWorker extends EventEmitter {
...workerConfig,
};

var tn = '';
if (Array.isArray(tasksName)) {
tn = tasksName.join('-');
} else {
tn = tasksName;
}

this.consumer = new KafkaConsumer(
{
'bootstrap.servers': workerConfig.kafkaServers,
'group.id': `melonade-${this.workerConfig.namespace}.client`,
'group.id': `melonade-${this.workerConfig.namespace}-client-${tn}`,
'enable.auto.commit': false,
...kafkaConfig,
},
{ 'auto.offset.reset': 'earliest' },
{ 'auto.offset.reset': 'latest' },
);

this.consumer.on('ready', () => {
Expand Down

0 comments on commit d0c5aa6

Please sign in to comment.