Created
December 13, 2016 18:12
-
-
Save bradvogel/872ea1e3ed39dd5351cbb5d43db326fa to your computer and use it in GitHub Desktop.
bull
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Bull = require('bull'); | |
var queue = new Bull('contacts', 6383, 'localhost'); | |
var concurrency = process.argv[2] ? parseInt(process.argv[2]) : 1; | |
function handler(job, done) { | |
console.log('processing job', job.jobId); | |
setTimeout(() => { | |
done(); | |
}, 5 * 1000); | |
} | |
queue.on('stalled', job => console.log('stalled: ', job)); | |
queue.process(handler, { | |
concurrency: concurrency | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Bull = require('bull'); | |
var queue = new Bull('contacts', 6383, 'localhost'); | |
var numEvents = process.argv[2] ? parseInt(process.argv[2]) : 1; | |
queue.on('ready', () => { | |
for (var i = 0; i < numEvents; i++) { | |
setTimeout(() => { | |
queue.add({}, { | |
removeOnComplete: true | |
}).then(() => { | |
console.log('published job'); | |
}); | |
}, i * 500); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment