I am using spring-kafka and the method annotated with @KafkaListener
is not called if the consumer.poll()
method does not return any message. Is it possible to enforce the calling of a method even if consumer.poll()
returns an empty list of messages using @KafkaListener
?
No, but you can set the idleEventInterval
on the listener container factory and then consume ListenerContainerIdleEvent
s; the event is emitted if a poll returns no records have been received during that interval.
Consume the events by implementing ApplicationListener<ListenerContainerIdleEvent>
or using an @EventListener
method that receives a ListenerContainerIdleEvent
.