#Documentation for using bull queue as task scheduler without using Cron.
1 messages · Page 1 of 1 (latest)
You can probably use repeated jobs for it, but there's no direct support from Nest in terms of decorators
https://docs.bullmq.io/guide/jobs/repeatable
The implementation is the same as using a cron decorator and putting a job to the a queue manually.
I'll add that I'm using the repeatable jobs with success. Bonus points for that:
- when using cron schedule, the job is only scheduled once — e.g. when you're running multiple instances, both can register
cleanuptask for* * * * * *and it will only be ran once (no duplicates) - it survives downtimes/restarts. The planned job is stored in redis, and is picked up if it was missed
- when you add bull-board ui to the mix, you can promote the scheduled jobs to run now, while they keep their schedule
The deduplication doesn't happen when using intervals though, since they're not set in time.
I have something like this in my module:
onModuleInit(): any {
this.queuesService.promoCode
.expirePromoCodes({ repeat: { cron: '* * * * *' } })
.catch(this.logger.error);
this.queuesService.storage
.deleteUnassigned({ repeat: { cron: '10 * * * *' } })
.catch(this.logger.error);
...
And my cron troubles are solved đŸ™‚