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

Taught in

References