There are a few choices of around scheduling messages to deliver in the future(inspiration from java.util.Timer) - a simple delay - this one will deliver the message in a minute:
long time = 60 * 1000; message.setLongProperty(ScheduledMessage.AMQ_SCHEDULED_DELAY, time);
Delivery at a fixed rate - this example will delivery 10 messages, waiting 10 seconds between each message - note the repeat count is 9 (9 + first one = 10).
For more advanced messaging you can use CRON scheduling - this one will deliver a message at 2AM on the 12 day of every month:
message.setStringProperty(ScheduledMessage.AMQ_SCHEDULED_CRON, "0 2 12 * *"); producer.send(message);
You can combine delays and repeats with CRON. For example, you may wish to send 10 messages, every 30 minutes, with a delay of 10 seconds between each one.
message.setStringProperty(ScheduledMessage.AMQ_SCHEDULED_CRON, "30 * * * *"); message.setLongProperty(ScheduledMessage.AMQ_SCHEDULED_DELAY, 10*1000); message.setLongProperty(ScheduledMessage.AMQ_SCHEDULED_PERIOD, 10*1000); message.setIntProperty(ScheduledMessage.AMQ_SCHEDULED_REPEAT, 9);
As I quickly realised whilst testing - having a persistent message scheduler that survives re-starts really needs management support - so that you can delete those pesky jobs that you accidentally scheduled ;). So there's JMX support - and the ActiveMQ Web Console has been updated too: