Chapter 13. Scheduling Messages
You can specify a time in the future, at the earliest, for a message to be delivered. This can be done by setting the _AMQ_SCHED_DELIVERY
scheduled delivery property before the message is sent.
The specified value must be a positive long
that corresponds to the time in milliseconds for the message to be delivered. Below is an example of sending a scheduled message using the JMS API.
// Create a message to be delivered in 5 seconds TextMessage message = session.createTextMessage("This is a scheduled message message that will be delivered in 5 sec."); message.setLongProperty("_AMQ_SCHED_DELIVERY", System.currentTimeMillis() + 5000); producer.send(message); ... // The message will not be received immediately, but 5 seconds later TextMessage messageReceived = (TextMessage) consumer.receive();
Scheduled messages can also be sent using the core API by setting the _AMQ_SCHED_DELIVERY
property before sending the message.