无法从Bull队列节点Js中删除可重复作业

时间:2019-03-07 04:31:42

标签: javascript node.js queue jobs

当我尝试使用此方法-removeRepeatableByKey时,我得到的removeRepeatableByKey不是函数错误。 queue_1.taskQueue.removeRepeatableByKey不是函数

我也无法通过taskQueue.removeRepeatable('task', { cron: '0 47 6 * * 4' });删除我的可重复工作

let jobOptions = {
        priority: queue_options.priority,
        repeat: { cron: '0 47 6 * * 4'},
        attempts: 3,
        removeOnComplete: true,
        jobId: queue_options.job_id,
        backoff: 3,
        timeout: 60000,
      };
      taskQueue.add('task', queue_options.data, jobOptions);

JOB的JSON:

{ id: "repeat:09854c8042eced1337a7d8eec9357528:1552526220000", name: "task", data: { eventName: "test", parameters: [ { my_JSON }, { my_JSON } ] }, opts: { repeat: { count: 1, cron: "0 47 6 * * 4", jobId: "myJobId" }, jobId: "repeat:09854c8042eced1337a7d8eec9357528:1552526220000", delay: 603096068, timestamp: 1551923123932, prevMillis: 1552526220000, priority: 1, attempts: 3, removeOnComplete: true, backoff: { type: "fixed", delay: 3 }, timeout: 60000 }, progress: 0, delay: 603096068, timestamp: 1551923123932, attemptsMade: 0, stacktrace: [ ], returnvalue: null, finishedOn: null, processedOn: null }

1 个答案:

答案 0 :(得分:0)

我现在可以删除可重复的作业。问题是我正在使用以下命令将作业添加到队列中:

let jobOptions = {
        priority: queue_options.priority,
        repeat: { cron: '0 47 6 * * 4' },
        attempts: 3,
        removeOnComplete: true,
        jobId: queue_options.job_id,
        backoff: 3,
        timeout: 60000,
      };
      taskQueue.add('task', queue_options.data, jobOptions);

并尝试删除作业,例如:

let job = await taskQueue.removeRepeatable('task', {cron : '0 47 6 * * 4'});

我通过传递jobOptions对其进行了修复,并且能够从队列中成功删除该工作。

let job = await taskQueue.removeRepeatable('task' jobOptions);