Skip to content

Instantly share code, notes, and snippets.

@myndzi
Last active August 29, 2015 14:02
Show Gist options
  • Save myndzi/999e0dde41ae33c09940 to your computer and use it in GitHub Desktop.
Save myndzi/999e0dde41ae33c09940 to your computer and use it in GitHub Desktop.
// config.amqp = connection parameters
var worker = new Worker(
extend({ }, {
exchange: 'exchange',
bindings: {
'exchange': [
// queue we process from
'class.method.job',
'class.method.settled'
]
},
log: log
}, config.amqp)
);
// log is a class with methods for 'trace', 'silly', 'info', 'warn', 'error'
// https://github.com/myndzi/logger
worker.consume('class.method.job', function (data) {
// return a promise for the completion of this job
});
worker.publish('class.method.job', { /* data */ }, { /* headers */ });
// the system recognizes a header called 'retry' that is an array of retry delays in seconds
// each retry shifts one off the front, waits, and tries again. there needs to be a separate
// worker that reads from the 'retry' queue and re-submits jobs
worker.bind('key', function (data) {
// this doesn't auto-fulfil messages to the .settled queue and lets you specify anything you want
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment