title: How can I control the rate at which Spring receives from a queue?
body: <p>I am using Spring's message-driven POJO framework (and <code>DefaultMessageListenerContainer</code> in particular) to listen to several queues and topics.</p>
  
  <p>In the case of one particularly queue, there is a need to slow the rate at which I drain the queue, on the order of one message every five minutes. The actual processing of the messages is a sub-second operation, but I would like the listener to sit idle for some time in between messages.</p>
  
  <p>I have created a bit of a hack, but it is decidedly sub-optimal: What I've done is to set the max concurrency to 1 and add a <code>Thread.sleep(..)</code> after processing each message. I would like to find a way instead to use the <code>DefaultMessageListenerContainer</code> to wait between attempts to receive, rather than causing the handler to do the waiting during the would-be processing of a message. </p>
  
  <p>I had considered if there was a <code>ScheduledExecutor</code> that would help, but I realize that the throttling would need to be done where the tasks are produced. Is there perhaps some method from <code>DefaultMessageListenerContainer</code> that I could override to accomplish what I'm after?</p>