Adding a queue or job
- Add the queue name to
APP_BULL_QUEUESinsrc/app/enums/app.enum.tswhen it is a shared queue. WhatsApp catalog is the exception that is not in the enum. Prefer the enum. BullModule.registerQueuein the producer module and inWorkerModule.- Put the processor under
src/workers/processors, extendingBaseQueueProcessorwhen you want Sentry on the terminal failure. - Inside the processor, enter
runWithTenantContextwith the tenant on the job payload. - Choose
attempts, backoff, and whetherjobIddedupes. Default retention used by several queues is 3 attempts and exponential backoff of 2 seconds. Webhook uses 8 and 5 seconds. Do not assume the default if you pass nothing. ReadDEFAULT_QUEUE_RETENTION_OPTIONS. - Throw if you want Bull to retry. Returning after a catch marks the job complete.
- Register the queue on Bull Board only if operators should see it. The current board route is
/admin/queuesand does not list every queue.
Schedulers belong on the scheduler process (src/main.scheduler.ts / scheduler module). PartitionMaintenanceService is the exception that is loaded by the worker. Do not add a second midnight cron that only logs. MidNightScheduleWorker already does that and performs no business work.
Enqueue from a request only after you accept that a crash between commit and queue.add drops the job. If the work must not be lost, write an outbox row in the transaction and let a listener enqueue.