I am working in java springboot, want to pause consumer for certain time period I am trying following code but looks like it is not working. Because when I debug code goes into 2nd if also. I am assuming when paused it shouldnt be in running state. Please guide me how can I manage this ?
@Scheduled(fixedDelay = 15000) // Check every 5 seconds
public void checkTopicMessageCount() {
if (Objects.requireNonNull(kafkaListenerEndpointRegistry.getListenerContainer("v2")).isRunning()) {
int a = 1;
}
kafkaListenerEndpointRegistry.getListenerContainer("v2").pause();
if (Objects.requireNonNull(kafkaListenerEndpointRegistry.getListenerContainer("v2")).isRunning()) {
int a = 1;
}
}
Below is my Kafka Listener config
@KafkaListener(topics = "${spring.kafka.topic.response}", groupId = "${spring.kafka.group-id}", id = "v2", info = "Consumer", clientIdPrefix = "consumer-v2")
1
Hi I have got the answer we will see isPaused instead of isRunning
1