I want to stop polling for a specific topic at a specific time.
For example, even if a message comes in to the TEST topic partition, the message is piled up in the partition from 00 to 01, and there is no consumption.
After 01 o'clock, I want to consume the message again on the TEST topic.
How to pause and resume?
Use the KafkaListenerEndpointRegistry
bean to control the lifecycle of the listener containers; you can stop and start them according to whatever conditions you desire.
You can also configure them to be stopped until you explicitly start them.
See https://docs.spring.io/spring-kafka/docs/current/reference/html/#kafkalistener-lifecycle.
@KafkaListener(id = "myContainer", topics = "myTopic", autoStartup = "false")
public void listen(...) { ... }
and
@Autowired
private KafkaListenerEndpointRegistry registry;
...
this.registry.getListenerContainer("myContainer").start();
...