Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Remember delayed job id in activejob

Oliver Günther14f4b77c7497
diff --git a/config/initializers/delayed_job_config.rb b/config/initializers/delayed_job_config.rb
index 079fe7ba0e2..c5dbfd6d6ac 100644
--- a/config/initializers/delayed_job_config.rb
+++ b/config/initializers/delayed_job_config.rb
@@ -42,3 +42,14 @@ end
# Do not retry jobs from delayed_job
# instead use 'retry_on' activejob functionality
Delayed::Worker.max_attempts = 1
+
+# Remember DJ id in the payload object
+class Delayed::ProviderJobIdPlugin < 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::ProviderJobIdPlugin