Vico
Vico

Reputation: 1256

BullMQ NestJS external process configuration

I'm trying to configure an external process because my jobs were stalling:

    BullModule.registerQueue({
      name: 'compute',
      processors: [
        {
          callback: compute,
          concurrency: 2,
        },
      ],
    }),

I've tried to set up concurrency as shown here, but it's not working. Since it's an external process, I can't use the @Processor decorator.

My jobs are reported as fails (even if they successfully end) because I've got this error:

Error: Missing lock for job 84 failed

After reading online, it appears that I can maybe increase the lockDuration parameter to avoid that, but same, I don't know where to setup that.

Can you help? Thanks!!

Upvotes: 0

Views: 664

Answers (1)

Hai Alison
Hai Alison

Reputation: 1403

if you want to set the lockDuration, set it when you create a new queue this is the code to set below:

export const bulkDiscountQueue = new Queue('bulk-discount-queue', {
  redis,
  settings: { lockDuration: 5 * 60 * 1000 }, //5 mins
});

also try to set maxStalledCount to 0, due to specific implementation Bull can overwrite real error with a useless Missing lock for job, and I hope this can help. ref

and your case register new queue by a module, do this:

BullModule.registerQueue({
  name: 'compute',
  processors: [
    {
      callback: compute,
      concurrency: 2,
    },
  ],
  settings: { lockDuration: 5 * 60 * 1000 },
});

Upvotes: 0

Related Questions