Get partition assigned by Kafka

774 views Asked by At

I’m using Quarkus Kafka consumer. And I need to know to which partitions my consumer has been assigned by Kafka broker. Any listener that I can use, just like the one that Kafka client provide. Otherwise how can I assign a specific partition in each of the nodes of my cluster?

Regards

1

There are 1 answers

1
Hitobat On

From the Quarkus docs, I think you can use rebalance listener. It should be called, because the initial assignment of partitions to your client (from no partitions to some partitions) can be considered as rebalance too.

https://quarkus.io/guides/kafka#consumer-rebalance-listener

The listener is invoked every time the consumer topic/partition assignment changes. For example, when the application starts, it invokes the partitionsAssigned callback with the initial set of topics/partitions associated with the consumer. If, later, this set changes, it calls the partitionsRevoked and partitionsAssigned callbacks again, so you can implement custom logic.