Reputation: 8096
I worked a little with the ActiveMQ scheduler plugin. This simplifies scheduling messages for delivery with a delay at low volume, but as I get into the 100ks of messages the system breaks down in two key ways.
The existing scheduler feels a little bolted on and does not perform as expected. So, rethinking the problem I would like to have a jobs
and jobs-scheduled
queue. Messages sent to the jobs-scheduled
queue will have a ttl
header with the unix timestamp for when it should be delivered. A process will run on a cron job which will take messages from the jobs-scheduled
queue and send it to the jobs
queue using a selector to just pick out the messages with an elapsed ttl convert_string_expressions:ttl < %(now)s
.
My two questions are:
Upvotes: 0
Views: 239
Reputation: 4316
Side note-- potentially off-topic.
I've had to solve a similar situation in the past where it made a lot of sense to load up the queues with messages ahead of time to cut down on the total transfer time.
I solved it by using Camel routes and a side-channel activation. Camel allows you to programmatically start and stop routes, so you can load up a queue with no consumers for the data for a given time period. Then using a dedicated queue for control you send the 'start' message. The control route receives the 'start' message, and then activates the main data processing route. You then need to configure some sort of 'stop' message semantic to be ready for the next time periods run.
Effectively, you get the delayed behavior pattern with much more control over scheduling and cut down on the data-to-queue loading time problem. You can also solve the scaling problem by loading the data across more than one queue.
Upvotes: -1
Reputation: 18376
ActiveMQ is a message broker not a job scheduler so what you are trying to do is really outside the scope of the what the broker is intended to do. Yes ActiveMQ does have a scheduled message feature but this is not intended for large scale job queue type work, it is a simple feature to provide some minimal delayed delivery.
What you are looking for sounds more like Quartz or some other batch job scheduling library. You could develop your own Job scheduler implementation for ActiveMQ or do something in a plugin but you are really trying to run against the grain of what a broker is meant to do which is deliver messages as quickly as possible in a decoupled manner.
Upvotes: 2