-
Notifications
You must be signed in to change notification settings - Fork 206
Closed
Description
I'm currently using DelayedJob with this custom plugin that allows me to access the provider_job_id from within the perform method of a job:
class Delayed::ActiveJobPlugin < Delayed::Plugin
callbacks do |lifecycle|
lifecycle.before(:invoke_job) do |job|
job.payload_object.job_data['provider_job_id'] = job.id if job.payload_object.respond_to?(:job_data)
end
end
end
Delayed::Worker.plugins << Delayed::ActiveJobPlugin
The Sidekiq adapter in Rails also does something similar:
I'm intending to migrate to Solid Queue but just wondered if this is an option currently? From looking at the source I don't see the job id being passed in. I have two use cases:
- Keeping track of a job that generates another job at the end of its run (so a kind of recurring job configurable by the user). I store the
job_idin the database so that I can destroy that job and schedule a new job if the user changes the time it should run. - Skipping the execution of a job if the object passed into the job has an
updated_atthat is greater than the job'screated_at. This signals that there's now a newer job scheduled that should take precedence. I use this for WebPush notifications.
Metadata
Metadata
Assignees
Labels
No labels