javacronactivemq-classicscheduleractivemq-artemis

Cron scheduler support in ActiveMQ Artemis


I am in the process of transitioning my ActiveMQ Classic-based project to ActiveMQ Artemis 2.19. (Target version for Artemis is preferred due to the project relying on Java 8.)

In ActiveMQ Classic, I have utilized the scheduler support for both delayed messages and cron-based messages. However, during the adaptation to ActiveMQ Artemis, I've noticed that scheduler support seems limited to delayed messages only.

Does ActiveMQ Artemis lack cron-based scheduler support?

Could you suggest an alternative or best practice to replace this feature in ActiveMQ Artemis, or is manual handling the only viable option moving forward?


Solution

  • ActiveMQ Artemis is not meant to be a complete re-implementation of the ActiveMQ Classic code-base with support for all the existing features. Artemis is a completely new implementation with support for the same protocols (i.e. OpenWire, AMQP, MQTT, STOMP) and many of the same features (or equivalents).

    As you note, you can use scheduled delivery but that only applies for a single message. Once that message is delivered and consumed it's gone which means you'll need to send another scheduled message. There is no automated, repeated delivery of the same message.

    Something like the quartz scheduler might be a good solution here because you could schedule all the tasks with it, and the scheduled task could send a message to a queue which is being monitored by your distributed workers. In this way you could separate the scheduling from the work distribution.

    At this point it doesn't make a lot of sense to me to implement advanced job scheduling functionality into the Artemis broker. It would be a fairly big chunk of work to do it "right" (e.g. with support for journal or database persistence), and there are things like Quartz which make it pretty easy for applications to implement themselves. That said, an in-memory scheduler probably wouldn't take a lot of work. If this is something you're interested in feel free to send a pull-request. We always welcome contributions!