Stefan Walther
Stefan Walther

Reputation: 938

Scheduled messages with RabbitMQ

I'm looking for a solution to have scheduled messages with RabbitMQ, so not only delaying the messages as described in several sources but schedule it to have a message e.g. every day.

If not RabbitMQ, any other solutions out there you can think of and you'd suggest for a microservices environment using a message-bus? So it's really about combining the concept of a task-scheduler and a message bus ...

Or is it better to use a job scheduler just to push messages to the message queue, e.g. using rundeck in combination with RabbitMQ?

Upvotes: 11

Views: 24381

Answers (2)

NewBee
NewBee

Reputation: 1469

You may try ActiveMQ, It supports crontab schedule, and it provides a web console to setup the schedule too. If you want to schedule from code, it may looks like:

MessageProducer producer = session.createProducer(destination);
TextMessage message = session.createTextMessage("test msg");
message.setStringProperty(ScheduledMessage.AMQ_SCHEDULED_CRON, "0 * * * *");
producer.send(message);

Upvotes: -1

Derick Bailey
Derick Bailey

Reputation: 72868

Or is it better to use a job scheduler just to push messages to the message queue, e.g. using rundeck in combination with RabbitMQ?

yes.

RabbitMQ is not designed to handle scheduling, and attempting to use it for that will just be painful (at best).

It is best to use another scheduling system, like cron jobs or rundeck or any of the other numerous scheduling tools available. From that tool, you can execute code that will push messages across RabbitMQ, triggering work in other parts of your system.

Upvotes: 28

Related Questions