We have our kafka consumer application where we have one consumer group and it gets connected to multiple topics using kafkajs node js library
const consumeMessages = async() = > {
const consumer =
kafka.consumer({groupId : 'test-group'})
await consumer.connect() await consumer
.subscribe({topic : 'test-topic', fromBeginning : true})
await consumer.run({
eachMessage : async({topic, partition, message}) =
> {console.log({
value : message.value.toString(),
})},
})
}
We want to change this approach where we want to have one consumer group for one topic . like if we have 5 topics we will have 5 consumer groups . In this case how to connect to multiple group Ids?
If I do it like this:
const consumer =
kafka.consumer({groupId : 'test-group'}, {groupId : 'test-group1'},
{groupId : 'test-group2'})
It's not connecting and throwing errors , cannot connect to the broker. Any idea how to achieve this?