Skip to content

Latest commit

 

History

History
37 lines (24 loc) · 1023 Bytes

README.md

File metadata and controls

37 lines (24 loc) · 1023 Bytes

node-amqp-schedule

Install

npm install amqp-schedule

Use with postwait/node-amqp.

Usage

var scheduler = require('ampq-schedule');
var delayedPublish = scheduler(conn); // conn is an amqp.Connection instance

// later

delayedPublish(exchangeName, routingKey, message, delayMs, messageOptions, callback);

// or

delayedPublish(exchangeName, routingKey, message, date, messageOptions, callback);

Details

delayedPublish creates a temporary queue with ttl and dead letter exchange. The queue expires if it's empty.

You can provide a second paramereter (options) to scheduler. options.prefix is the temp queue name prefix, defaults to schedule.. The temp queue expires after delay + options.threshold, threshold defaults to 10 seconds.

So if you want to publish a message 1 min later in the exchange foo with the routing key bar, the message will be hold in a queue named schedule.foo.bar.60000.