Is there a way to manually trigger a rebalance without restarting a spring kafka container (and before the metadata max age)? Since Kafka 2.6, there is enforceRebalance() to trigger the rebalance from the consumer API but it is private in the spring kafka containers.
You can add the Consumer
as a parameter to the listener and call enforceRabalance()
on it and the rebalance will occur on the next poll.
If the container is idle, you can set an idleEventInterval
and the consumer is available in the ListenerContainerIdleEvent
.
https://docs.spring.io/spring-kafka/docs/current/reference/html/#idle-containers
https://docs.spring.io/spring-kafka/docs/current/reference/html/#event-consumption