I want to pause the Kafka Listener.
- I call http://localhost:8080/pause to the pause the container
- I send data on the topic.
- Consumer starts consuming the message
I expected that consumer would be paused but message is still being read from Kafka topic. How can i pause the consumer? I am using 2.5.0 (Spring Boot Parent)
@KafkaListener(id="foo" ,topics = "mytopic-3", concurrency = "3", groupId = "mytopic-1-groupid")
@Autowired
private KafkaListenerEndpointRegistry kafkaListenerEndpointRegistry;
@GetMapping("/pause")
public void pause( )
{
System.out.println(" Pausing Kafka Listener");
kafkaListenerEndpointRegistry.getListenerContainer("foo").pause();
}
@Configuration
@EnableKafka
public class KafkaConsumerConfig implements KafkaListenerConfigurer {
@Autowired
private LocalValidatorFactoryBean validator;
@Override
public void configureKafkaListeners(KafkaListenerEndpointRegistrar registrar) {
registrar.setValidator(this.validator);
}