How to tell spring-kafka consumer to stop consuming, at runtime?

Solution 1:

Give each listener an id attribute; you can then use the KafkaListenerEndpointRegistry bean to get a reference the listener container which you can then start and stop: getListenerContainer("myId").stop().

This is documented here.