Skip to content

Instantly share code, notes, and snippets.

@ynwd
Created February 13, 2022 04:43
Show Gist options
  • Save ynwd/d5eccfcfcc674afcc887687982b540ca to your computer and use it in GitHub Desktop.
Save ynwd/d5eccfcfcc674afcc887687982b540ca to your computer and use it in GitHub Desktop.
Very Simple Bull Queue without Redis

Very Simple Bull Queue without Redis

node main.js
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