Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

re enqueue job as the first element in the :waiting list #1628

Open
nicosefer opened this issue Jan 30, 2020 · 3 comments
Open

re enqueue job as the first element in the :waiting list #1628

nicosefer opened this issue Jan 30, 2020 · 3 comments

Comments

@nicosefer
Copy link

Description

Hi @manast ! First of all, thanks for this awesome library!

When a job fails (with N attempts and backoff = 0 ) it gets re-enqueued on the :waiting list as the last item to be processed (left-side in a FIFO queue). We have a pool of workers that processes jobs from different queues in a round-robin approach and we need to re-process that failed job in the next iteration. Is there any way to put that job as the first (right-side) element in the waiting list ?

Thanks in advance for your time and support!

@manast
Copy link
Member

manast commented Jan 31, 2020

I think that if you use a backoff of say 1ms then the job would go to the delay set, then after 1ms moved back at the first position of the queue.

@nicosefer
Copy link
Author

nicosefer commented Mar 12, 2020

Hey @manast , sorry for the delayed response!
I've tried with so many options ( including a backoff of 1 ms) and i could not succeed

Here is a code snippet with the case:

import Queue from "bull";

var queue = new Queue("foo", "redis://redis:6379", {
  defaultJobOptions: {
    attempts: Number.MAX_SAFE_INTEGER,
    backoff: {
      type: "fixed",
      delay: 1
    },
    removeOnComplete: true
  }
});

queue.add(1, { jobId: 1 });
queue.add(2, { jobId: 2 });
queue.add(3, { jobId: 3 });

queue.process(async job => {
  console.log("process job", job.id);
  return Promise.reject(new Error("bar"));
});

and the output is the following:

process job 1
process job 2
process job 3

@manast
Copy link
Member

manast commented Mar 14, 2020

then it is not possible with current implementation...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants