tulios / kafkajs

A modern Apache Kafka client for node.js
https://kafka.js.org
MIT License
3.73k stars 526 forks source link

Print Rebalancing/Rebalanced Consumer Status #942

Open teukuamru opened 3 years ago

teukuamru commented 3 years ago

In kafka-node, I could do it like this

consumerGroup.on('rebalancing', () => {
  console.log('Consumer rebalancing...')
})

consumerGroup.on('rebalanced', () => {
  console.log('Consumer rebalanced!')
})

How can I achieve this in kafkajs?

ankon commented 3 years ago

There is a instrumentation event for when a consumer joined a group, which should be roughly matching the rebalanced state from your example: https://kafka.js.org/docs/instrumentation-events#consumer