I am using Spring's message-based POJO framework (and DefaultMessageListenerContainer in particular) to listen on multiple queues and topics.
In the case of one particular queue, it is necessary to slow down the speed at which I reset the queue, on the order of one message every five minutes. Actual message processing is auxiliary, but I would like the listener to sit idle for a while between messages.
I created a little hack, but it is clearly not optimal: I did to set max concurrency to 1 and add Thread.sleep(..) after processing each message. I would like to find a way instead to use the DefaultMessageListenerContainer to wait between retrieval attempts, instead of forcing the handler to wait while future processing the message.
I wondered if there was a ScheduledExecutor that would help, but I understand that throttling should be done where the tasks are performed. Is there any possible method from DefaultMessageListenerContainer that I could override to accomplish what I need?
source share