-
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
Feature Request: Remove completed/failed job after time interval #1387
Comments
I wouldn't say the way you want to use Bull to achieve this is very straightforward. Why not just to take (I don't think this feature is totally useless; and it's indeed very easy to implement manually using delayed jobs. You just don't need to depend on Bull to implement this feature) |
I am totally fine with implementing this in user land, I just wanted to make sure whether this would be something that might be contributed back to the core or not (since there are quite some similar issues around). Thank you for your quick response! |
Is this option already added? or it should be done on the user side? |
once a job is getting completed in queue.process later on I am trying to take a instance of queue by job id now I am trying to move the job to failed (moveToFailed) but the same jobid is reflecting in both completed and failed (in arena) can you suggest me what should i do so that jobid will removed from completed and will only reflect in failed? |
For those that got here from a google search, this is supported through https://docs.bullmq.io/guide/queues/auto-removal-of-jobs#keep-jobs-based-on-their-age |
Real World Use-Case
You use bulljs as a worker for sending emails.
You want to make sure a certain email is not sent a second time until a certain time period has elapsed.
The current state
It is possible to ensure a job is not enqueued twice by using the
jobId
option.It is possible to ensure that a job is deleted after it has been completed successfully with the
removeOnComplete
optionWhat is missing
There is currently no option for specifying that a job should be automatically deleted after it has completed successfully AND a certain time period has elapsed.
Workarounds
Create a separate Queue with "remove job operations"
Instead of having one queue you have two. One which does the actual job (e.g. sending emails) and one that includes the
Possible Solution
Adding a new option that will make this possible.
removeOnCompleteAfter
which default value isundefined
. IfremoveOnCompleteAfter
is set to a number it will override the behavior ofremoveOnComplete
.removeOnFailAfter
which default value isundefined
. IfremoveOnFailAfter
is set to a number it will override the behavior ofremoveOnFail
.Change
removeOnComplete
behavior with backward compatibility in mindThe changed API could look similar to this:
Similar Issues
I think that the workaround mentioned above ☝️might also be a valid workaround for issue #854 and #1387 (at least for cleaning successful jobs).
The text was updated successfully, but these errors were encountered: