-
Problem DescriptionHi there, my team is looking for some help with the usage of ConsumerGroup's Consume() method, currently we have a for loop
We are following what is recommended in the method comments and putting it inside an infinite loop but we are wondering what is the best practice to handle the errors returned from IMO not returning errors and having the for loop to retry should be OK to handle most if not all of the errors we will be facing? Would like to hear more inputs, thanks in advance! |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
Usually the errors returned by In my experience, I've seen that most cases devs just return the error to close the consumer loop, and try to recreate |
Beta Was this translation helpful? Give feedback.
Usually the errors returned by
.Consume
are not recoverable,newSession
will try the best effort, up toc.config.Consumer.Group.Rebalance.Retry.Max
attempts to get a valid consumer group, assuming the preconditions are correct (brokers reachables, timeout configured correctly, topics exists, ssl certificates are valid and aren't expired, etc)https://github.com/Shopify/sarama/blob/65f0fec86aabe011db77ad641d31fddf14f3ca41/consumer_group.go#L205
In my experience, I've seen that most cases devs just return the error to close the consumer loop, and try to recreate
NewConsumerGroup
, which basically tries to recreate the client connection, you could potentially have a circuit breaker, or some m…