-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Possible to push (unattempted) jobs back on a queue? #1546
Comments
After looking into this a little more, moveToDelayed seems to do what I'm wanting but it's not documented, not present in the TS definition, and I have to pass |
It is not documented for good reasons, since it is an internal API. If you call that method from the processor you will most likely create undesired side effects since the job will still try to complete and at the same time it is moved to the delayed set instead of being in the Active list. |
Gotcha. So this third outcome is something you're potentially open to adding to the project? Something like this?
|
I've wanted this for a long time. Would be great to see it in Bull. |
+1 - this is very necessary to handle more complex rate limiting scenarios. @chris72205 - did you ever find a better workaround? |
@theoephraim yes and no... the workaround I settled on is a bit hacky but ultimately worked. I ended up adding an "internal" property to our jobs that we use to store some meta info about the job itself (number of retries, previous errors, etc) and do a check on the jobs when they emit a
I also added some logic in the |
Do you think this will help in resolving this issue? #1753 |
@manast - that could help some for some simple scenarios where jobs can be bucketed easily. In my case, I have several different rate limits that need to be checked (per user, per org, and then per api token being used), so a single bucket doesn't work. Additionally, I may make an api request and get back a "youve been rate limited" response. In any of these cases, I just want to retry the job after some delay, but not count it as an "attempt" in the normal retry logic or use the normal exponential backoff setup. |
@chris72205 thanks for taking the time to explain your solution - very helpful. I already have a wrapper around each job handler, so was able to do something similar and re-enqueue a new job, but I'll see if hooking into the backoff strategies or error event handler may simplify some things. Cheers! |
We have a use case where we process jobs and rate limit them based on some property (
property A
) in the job payload. For this reason, we cannot easily use the built in Rate Limiter (as far as I know) without creating different queues for each variation ofproperty A
.Is there a way to put a job back on the queue without affecting it's retry count? I'm thinking of something similar to a
nack
in RabbitMQ. Something else I initially thought of is to simply create a new job but then we lose all of the retry functionality and history for the original one.The text was updated successfully, but these errors were encountered: