diff --git a/packages/job-queue-plugin/src/bullmq/bullmq-job-queue-strategy.ts b/packages/job-queue-plugin/src/bullmq/bullmq-job-queue-strategy.ts index 06dc6b28c6..888ed4ca2c 100644 --- a/packages/job-queue-plugin/src/bullmq/bullmq-job-queue-strategy.ts +++ b/packages/job-queue-plugin/src/bullmq/bullmq-job-queue-strategy.ts @@ -52,21 +52,26 @@ export class BullMQJobQueueStrategy implements InspectableJobQueueStrategy { private readonly CANCEL_JOB_CHANNEL = 'cancel-job'; private readonly CANCELLED_JOB_LIST_NAME = 'vendure:cancelled-jobs'; - async init(injector: Injector): Promise { + private initOptions(injector: Injector): BullMQPluginOptions { const options = injector.get(BULLMQ_PLUGIN_OPTIONS); - this.options = { - ...options, - workerOptions: { - removeOnComplete: options.workerOptions?.removeOnComplete ?? { + options.workerOptions = { + ...(options.workerOptions ?? { + removeOnComplete: { age: 60 * 60 * 24 * 30, count: 5000, }, - removeOnFail: options.workerOptions?.removeOnFail ?? { + removeOnFail: { age: 60 * 60 * 24 * 30, count: 5000, }, - }, - }; + }) + } + return options + } + + async init(injector: Injector): Promise { + const options = this.initOptions(injector); + this.options = options; this.connectionOptions = options.connection ?? ({ @@ -413,8 +418,9 @@ export class BullMQJobQueueStrategy implements InspectableJobQueueStrategy { args: Args, ): Promise { return new Promise((resolve, reject) => { + const prefix = this.options.workerOptions?.prefix ?? 'bull'; (this.redisConnection as any)[scriptDef.name]( - `bull:${this.queue.name}:`, + `${prefix}:${this.queue.name}:`, ...args, (err: any, result: any) => { if (err) {