#Documentation for using bull queue as task scheduler without using Cron.

1 messages · Page 1 of 1 (latest)

mellow shuttle
#

We would like to use Bull as our scheduler and not rely on the server to initiate the job.

trim rapids
violet solar
#

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 cleanup task 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 đŸ™‚