Closed raulnegreiros closed 1 year ago
When you call Consume on your consumer group instance, you pass a parent context.Context which will be passed through to the session and can be used to interrupt it and stop consumption: https://github.com/Shopify/sarama/blob/83d633e6e4f71b402df5e9c53ad5c1c334b7065d/consumer_group.go#L44
So you'd cancel that context to break out of the existing consumption and not call client.Consume(...)
again until you are ready to re-join the group and consume again.
thanks for the clarification @dnwe
Glad I could help!
Hi @dnwe ,
I just have modified the consumer group example to fit the described behaviour, but seems the partition rebalance is triggered, maybe it blocks the poll
call to the broker or maybe I can be misunderstood the steps.
On top of what @raulnegreiros said, I think in Java it is also possible to pause consumption only for some partition(s). With the suggestion above, you stop consumption of all partitions.
Or this is an alternative: https://docs.confluent.io/platform/current/clients/confluent-kafka-go/index.html#Consumer.Pause
Thank you for taking the time to raise this issue. However, it has not had any activity on it in the past 90 days and will be closed in 30 days if no updates occur. Please check if the main branch has already resolved the issue since it was raised. If you believe the issue is still valid and you would like input from the maintainers then please comment to ask for it to be reviewed.
Is there a way to control the consumption flow? I know that the Kafka Java API has the
pause
andresume
methods, but I don't find something similar with Sarama. Which is the recommended way to pause the consumption while the processing mechanism has some problem (some database connection issue, for example)?