RedisSMQ / Docs / Scheduling Messages
Starting with version 1.0.19, RedisSMQ enables you to schedule a one-time or repeating messages in your MQ server.
To set up scheduling parameters for a given message, the ProducibleMessage Class provides:
- ProducibleMessage.setScheduledCRON()
- ProducibleMessage.setScheduledDelay()
- ProducibleMessage.setScheduledRepeat()
- ProducibleMessage.setScheduledRepeatPeriod()
You can publish scheduled messages, as any other message, using the Producer.produce() method.
'use strict';
const { ProducibleMessage } = require('redis-smq');
const msg = new ProducibleMessage();
msg
.setBody({ hello: 'world' })
.setScheduledCRON(`0 0 * * * *`)
.setQueue('test_queue');
producer.produce(msg, (err, messageIds) => {
if (err) console.error(err);
else console.log('Message has been successfully scheduled. Message IDs are: ', messageIds.join(','));
});
For managing scheduled messages see:
Scheduled messages may be also managed using the HTTP API Interface or from your browser with the help of the Web UI.