-
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
Removing repeatable jobs by data passed in queue.add #2030
Comments
The ergonomics of repeatable jobs are not very nice atm, however can't you use the "name" field and correlate using that? |
@manast thank you for the response! I could do that, yes - it's just that currently I'm using different Are there short-term plans for improving the ergonomics of repeatable jobs? |
I am also having trouble working around repeatable jobs. I simply want to cancel particular repeatable jobs by some sort of known ID. It seems that the APIs make it quite challenging to do so. Why can't we simply call something like @yairk Were you able to curate some sort of solution? |
When I call [
{
key: '__default__::::* * * * *',
name: '__default__',
id: null,
endDate: null,
tz: null,
cron: '* * * * *',
every: null,
next: 1623336240000
}
] It seems weird that none of the information is passed through? However, the job object passed into the process function holds a lot of valuable information: Job {
opts: {
repeat: { count: 9, cron: '* * * * *' },
jobId: 'repeat:06ff7e943c0b9a35a957a28ad1155a1b:1623279600000',
delay: 59987,
timestamp: 1623279540013,
prevMillis: 1623279600000,
removeOnComplete: 100,
attempts: 1,
backoff: undefined
},
... Why can we not simply remove by said |
@croossin because the jobId is for one iteration of the repeatable job. A repeatable job is some metadata that is used to determine when the next job should be added to the queue. |
@croossin unfortunately I was unable to come up with a decent solution other than correlation based on |
I made a small change where the repeat key is also stored in the Job returned by queue##add (or when getting any repeatable job for that matter), I know it is not a great solution but maybe it makes it easier for you: #2106 |
Yes, that the example, you just use |
But there is a problem. When removing a job with key one last delayed job is still not removed, issue here |
If I understand correctly, repeatable jobs are created via
queue.add()
by passing therepeat
option as described e.g. here.When calling getRepeatableJobs, however, all of the data that was passed to
queue.add()
is not returned. Instead, I only get the key, name, id, etc.In my use case, I am creating a repeatable job while passing a
type
field in the job's data. If I then want to cancel all of the repeatable jobs of that type, how would I go about doing that? The only way I could so far come up with is to get all of the delayed jobs, filter the ones with the right type, and then retrieve all the repeatable jobs and "somehow" correlate their keys/ids with the delayed jobs.Is there a better way to achieve this? If not, what's the safest way to correlate a delayed job with its repeatable job?
Bull version
1.14.8
The text was updated successfully, but these errors were encountered: