-
Notifications
You must be signed in to change notification settings - Fork 410
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
Repeatable Jobs - Ability to Upsert/Remove Job via Job ID Alone #2612
Comments
For anyone stumbled in this issue, const job = queue.add('name', data, {
repeat: {
// repeat opts,
}
})
const ok = await conn.set("repeatable-job-id", job.repeatJobKey) and when you want to remove the job, query the key and const key = await conn.get("repeatable-job-id")
if(key) await queue.removeRepeatableByKey(key)
const ok = await conn.del("repeatable-job-id") I don't know if this hack is truly safe, but I'm using it right now, and I haven't found a problem yet. |
This is not safe because based on repeat options, you can have multiple jobs for the same job id. |
This has been now implemented using job schedulers: https://docs.bullmq.io/guide/job-schedulers |
Is your feature request related to a problem? Please describe.
I'm in the process of creating middleware for a microservices framework which allows services to run on a given schedule via BullMQ. The repeat options are provided in the service metadata as JSON configuration and the repeatable job is created when the service broker is initialized via the middleware. The issue I'm facing is that if the repeat job options are changed and service restarted, it would create two separate repeatable jobs.
Describe the solution you'd like
Describe alternatives you've considered
I understand that I can create a database table and store the repeatJobKey provided after calling the queue add() method and then use that value to call removeRepeatableByKey but it seems overkill for this purpose.
The text was updated successfully, but these errors were encountered: