node main.js
Created
February 13, 2022 04:43
-
-
Save ynwd/d5eccfcfcc674afcc887687982b540ca to your computer and use it in GitHub Desktop.
Very Simple Bull Queue without Redis
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
const Queue = require('bull') | |
const q = new Queue('my-first-queue') | |
setTimeout(async () => { | |
const data = { message: "my task" } | |
await q.add(data) | |
}, 5000) | |
q.process((job, done) => { | |
done(null, 'succes') | |
}) | |
q.on('completed', (job) => { | |
console.info( | |
`${job.queue.name} task has been completed with message: "${job.data.message}" on: ${new Date().toLocaleTimeString()}` | |
) | |
job.remove() | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment