Rails 4.2 get delayed job id from active job -
any idea how delayed::job id activejob enqueuing? when enqueue job instance of activejob::base @job_id, job id seems internal activejob. best guess far walk down created jobs:
active_job_id = generatereportjob.perform_later(self.id).job_id delayed_job = delayed::job.order(id: :desc).limit(5).detect |job| yaml.load(job.handler).job_data['job_id'] == active_job_id end but seems kinds of hacky. kind of surprised activejob isn't returning id delayed::job, since explicitly returned when job gets enqueued.
== edit
looks i'm not 1 (https://github.com/rails/rails/issues/18821)
in case finds in future: rails accepted patch allow id provider_job_id in rails 5. can work patch like
activejob::queueadapters::delayedjobadapter.singleton_class.prepend(module.new def enqueue(job) provider_job = super job.provider_job_id = provider_job.id provider_job end def enqueue_at(job, timestamp) provider_job = super job.provider_job_id = provider_job.id provider_job end end)
Comments
Post a Comment