zio-kafka icon indicating copy to clipboard operation
zio-kafka copied to clipboard

Close consumer when it cannot connect to the broker

Open egast opened this issue 4 years ago • 8 comments

Add option to close the consumer when it is unable to connect to the broker. This should be configurable i.e. after some timeout and/or after x amount of retries.

egast avatar May 18 '20 08:05 egast

I would very much love to see this! It is extremely annoying to have a consumer hang when it cannot connect to a broker.

WDYT @iravid ?

saraiva132 avatar Jun 13 '20 16:06 saraiva132

As a workaround, have you considered a .timeout on the stream?

svroonland avatar Jun 14 '20 12:06 svroonland

@egast @saraiva132 Are you by any chance familiar which how to get connection status or something from the org.apache.kafka.clients.consumer.Consumer or some settings that control the behavior on connection timeout?

svroonland avatar Sep 27 '20 18:09 svroonland

@svroonland I don't know if you can get the Kafka connection status from a KafkaConsumer. I think the connection retry behavior is done by the consumer client. I know that Akka Kafka Streams does offer the "close consumer if it cannot connect to Kafka", so I took a quick look at how they do it and from what I understand they just periodically try to get the topic metadata to see if Kafka is still available. Maybe something similar can be implemented for zio-kafka.

egast avatar Sep 28 '20 07:09 egast

We could perhaps do something with the lack of a partitions assigned event from the RebalanceListener.

svroonland avatar Apr 04 '24 19:04 svroonland

We could perhaps do something with the lack of a partitions assigned event from the RebalanceListener.

This would exclude use case that have extra instances standing by. This includes redeployments where you first start new instances, and then stop the old instances.

erikvanoosten avatar Apr 05 '24 06:04 erikvanoosten

Not sure, but do those instances get an empty list of assigned partitions perhaps?

svroonland avatar Apr 05 '24 07:04 svroonland

Not sure, but do those instances get an empty list of assigned partitions perhaps?

Not sure either. It might be that the rebalance listener would not be invoked at all.

erikvanoosten avatar Apr 05 '24 14:04 erikvanoosten