Scheduling messages with ActiveMQ 5.9.1 embedded in Tomcat 7 with Spring
I've managed to configure ActiveMQ to work either as a JNDI resource (in context.xml) or as a Spring set of beans. In either case everything works fine, excepted to have messages scheduled with a delay.
I'll let you know whether I manage to complete my task! :)
P.S.: I'm sorry for seeing my message posted twice, as I took care to delete the first one (declared to being not yet submitted to the mailing list) before sending the second one; I ignored messages are actually queued (couldn't they in this context? :) )
Ok, I've worked it out.
That link was inspiring! I understood that the Spring configuration was everything I needed. So I payed more attention to the wordings in the relevant page (I repeat it here): it's written that ActiveMQ from version 5.4 has an optional persistent scheduler (bold is mine). So, I tried to put up a persistent broker (attribute persitent = "true"), I added that attribute (schedulerSupport = "true") and everything works as expected.
For double checking it I put persistency to false and the delaying turned off.
Have you considered using Quartz, or another approach to scheduling?
I like to keep scheduling outside of the messaging layer since they are very different responsibilities. Especially with an embedded broker, any benefit with using ActiveMQ's scheduler seems to be eliminated (that is, having a scheduler running on a server separate from the application).
Think about the case of needing to perform maintenance on the scheduler (e.g. purging or suspending scheduled jobs). With ActiveMQ, that means the ActiveMQ messaging functions may be impacted, even if only for a brief period of time.