I want to access my ActiveRecord job item after enqueueing a task
我想在排队任务后访问我的ActiveRecord工作项
job = MyCustomJob.perform_later
Job
is a MyCustomJob
, but how I can access it without doing something like Delayed::Job.last
?
Job是一个MyCustomJob,但是如何在不执行Delayed :: Job.last之类的情况下访问它?
1 个解决方案
#1
1
job.provider_job_id
is the Delayed::Job
's id
so you could do Delayed::Job.find(job.provider_job_id)
.
job.provider_job_id是Delayed :: Job的id,所以你可以做Delayed :: Job.find(job.provider_job_id)。
Code is here: https://github.com/rails/rails/blob/master/activejob/lib/active_job/queue_adapters/delayed_job_adapter.rb#L20
代码在这里:https://github.com/rails/rails/blob/master/activejob/lib/active_job/queue_adapters/delayed_job_adapter.rb#L20
#1
1
job.provider_job_id
is the Delayed::Job
's id
so you could do Delayed::Job.find(job.provider_job_id)
.
job.provider_job_id是Delayed :: Job的id,所以你可以做Delayed :: Job.find(job.provider_job_id)。
Code is here: https://github.com/rails/rails/blob/master/activejob/lib/active_job/queue_adapters/delayed_job_adapter.rb#L20
代码在这里:https://github.com/rails/rails/blob/master/activejob/lib/active_job/queue_adapters/delayed_job_adapter.rb#L20