简体   繁体   中英

Unable to remove Repeatable Job From Bull Queue Node Js

When i tried using this method - removeRepeatableByKey I am getting removeRepeatableByKey is not a function error. queue_1.taskQueue.removeRepeatableByKey is not a function

I am not able to remove my repeatable job by taskQueue.removeRepeatable('task', { cron: '0 47 6 * * 4' }); this too

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);

JSON of the JOB:

{ 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 }

I am able to remove the repeatable job now. The problem was i am adding the job to the queue with:

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);

And trying to remove the job like:

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

I fixed it by passing the jobOptions and i was able to successfully remove the job from the queue.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM