Getting messages from queue after specific period of time


EJB programming & troubleshooting: Getting messages from queue after specific period of time

  1. Hello Can anybody give advice about accomplishing following requirement in handling message from queue? Requirement: Message is sent to queue by the producer with some time information (in header or may be message property). This information tells container that it should pick MDB for the message processing only after the specified amount of time is passed (after message arrival). Ex: message arrives to queue at time X, with the time 5000 milliseconds. Message waits 5 seconds in queue and started being processed at time X + 5000.
  2. In other words required implementation similar to java.util.concurrent.DelayQueue - A queue of elements, in which an element can only be taken when its delay has expired.
  3. I've searched the forum and found that there already exists discussion with same topic: It suggests using server specific property. For JBoss: jmsMsg.setLongProperty("JMS_JBOSS_SCHEDULED_DELIVERY", timeToDeliver); Another question arises: does anybody know how the delivery is accomplished internally by the server? I mean whether the message is sent immediately after queueSender.send(jmsMsg); and then picked up from queue at specified time or whether the message is sent to queue at the specified time?