Reputation: 5031
we are using @RabbitListener to listen to the queue and when there are messages we process them. However I want to do some reporting task when queue is empty, this happens when our app just processed tons of messages in the queue and no more message for a while. that's the time I want to report. How can i do that with @RabbitListener?
here is my code:
@RabbitListener(queues = "${consumer.queue}", containerFactory = "ListenerContainerFactory")
public void handleMessage(Message message) {
processEvent(message);
}
Upvotes: 0
Views: 729
Reputation: 174554
As I answered your other question a few weeks ago there is no mechanism in AMQP (and hence Spring AMQP) to notify the consumer that there are currently no messages in the queue.
We could modify the container to fire an ApplicationEvent
once, when no message is found after messages have been processed, but that would require a modification to the framework. Your listener would have to implement ApplicationListener
to get such an event.
Feel free to open a New Feature JIRA Issue if you want and we might be able to take a look at it.
Upvotes: 1