ConsumerRebalanceListener
A kafka-python class you subclass to run your own code when a consumer gains or loses partitions during a rebalance.
In more detail
on_partitions_revoked runs before partitions are taken away, which is the place to commit or save state. on_partitions_assigned runs after new partitions arrive and before records from them are returned. You pass the listener to subscribe.
Example
c.subscribe(['events'], listener=Report())Related terms
- rebalance — The process in which a consumer group redistributes partitions among its members after one joins, leaves or is judged dead.
- partition assignment — The decision about which consumer in a group reads which partitions.
- callback function — A function you hand to other code so that it can call it later, for example when a timer fires or an event happens.
Taught in
- Consumer Groups And Partition Assignment — Apache Kafka & Event Streaming
- Rebalancing And Its Cost — Apache Kafka & Event Streaming