Skip to content

Commit

Permalink
fix: allow attaching job name to processors
Browse files Browse the repository at this point in the history
Signed-off-by: Brent Hoover <[email protected]>
  • Loading branch information
Brent Hoover authored and vanpho93 committed May 19, 2023
1 parent b1c0d89 commit ee4d9e7
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion packages/api-plugin-bull-queue/src/api/createQueue.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,23 @@ export default function createQueue(context, queueName, options = defaultOptions
const newQueue = new Queue(queueName, options.url ?? REDIS_SERVER, options);
context.bullQueue.jobQueues[queueName] = newQueue;
if (REACTION_WORKERS_ENABLED) { // If workers are not enabled, allow adding jobs to queue but don't process them
newQueue.process((job) => processorFn(job.data, job));
if (options.jobName) {
newQueue.process(options.jobName, (job) => processorFn(job.data, job));
} else {
newQueue.process((job) => processorFn(job.data, job));
}
}

newQueue.on("error", (error) => {
Logger.error({ error, queueName, ...logCtx }, "Error processing background job");
});

newQueue.on("stalled", (job) => {
Logger.error({ queueName, options, job, ...logCtx }, "Job stalled");
});

newQueue.on("failed", (job, err) => {
Logger.error({ ...err, ...logCtx }, "Job process failed");
});
return newQueue;
}

0 comments on commit ee4d9e7

Please sign in to comment.