Reputation: 42594
I have a service that is processing jobs that can take up to 24 hours. When the service gets restarted, active jobs get stalled and are automatically resumed. As you can imagine, the service could get restarted multiple time in a 24 hour period, so I would need to increase the maxStalledCount
as 1
is unlikely to be enough. The problem is that I don't know where I need to set that option. It's part of the WorkerOptions
, but I don't know where those are set:
https://api.docs.bullmq.io/interfaces/v5.WorkerOptions.html#maxStalledCount
Since I'm using NestJS
, my worker extends WorkerHost
, which has a Worker
, but isn't a Worker
. It seems to be creating it internally and I'm not finding any way to pass WorkerOptions
to it.
get worker(): T {
if (!this._worker) {
throw new Error(
'"Worker" has not yet been initialized. Make sure to interact with worker instances after the "onModuleInit" lifecycle hook is triggered for example, in the "onApplicationBootstrap" hook, or if "manualRegistration" is set to true make sure to call "BullRegistrar.register()"',
);
}
return this._worker;
}
Source: https://github.com/nestjs/bull/blob/master/packages/bullmq/lib/hosts/worker-host.class.ts
This is the best clue I have so far, but I'm not finding anything about it in the documentation: https://docs.nestjs.com/techniques/queues
Does anyone have any insight into how to increase the maxStalledCount
with the NestJS
implementation of BullMQ
?
Upvotes: 0
Views: 117
Reputation: 42594
By reading through the code, I found the answer:
@Processor('name', {
maxStalledCount: 10000,
})
I might raise a PR to add it to the documentation.
Upvotes: 0