Hi Aditya,
Thanks for the KIP. I've only taken a quick look so far, but here's an initial 
comment.

AS1: One of the mistakes in the Kafka consumer API today is that the 
`subscribe(Collection<String>, ConsumerRebalanceListener)` does two jobs. 
First, it replaces the rebalance listener (when you might assume that the 
listener applies only to rebalance changes resulting from this call to 
subscribe). Second, it changes the subscription. If the second of these throws 
an exception, the first will still occur. It's a bit of a mess. I suggest you 
have a `Consumer.setRebalanceHandler(RebalanceHandler)` method and do not add a 
new override for `Consumer.subscribe`.

Thanks,
Andrew

On 2026/04/01 15:16:36 Aditya Kousik wrote:
> Hi all,
> 
> I'd like to start a discussion on KIP-1306: RebalanceHandler: Consumer-Aware 
> Rebalance Callback.
> 
> https://cwiki.apache.org/confluence/display/KAFKA/KIP-1306%3A+RebalanceHandler%3A+Consumer-Aware+Rebalance+Callback
> 
> Spring Kafka, SmallRye, and Micronaut all pass the consumer into rebalance 
> callbacks; the client doesn't. The standard workaround of 
> constructor-injecting a full Consumer reference allows dangerous operations 
> like poll() and close() inside a callback. This KIP proposes 
> RebalanceHandler, with a RebalanceConsumerView that exposes only safe 
> operations, making misuse a compile error.
> 
> Looking forward to your feedback.
> 
> Thanks
> 

Reply via email to