diff --git a/lib/active_job/queue_adapters/qu_adapter.rb b/lib/active_job/queue_adapters/qu_adapter.rb index 7e69229801..cdf4ae4ce9 100644 --- a/lib/active_job/queue_adapters/qu_adapter.rb +++ b/lib/active_job/queue_adapters/qu_adapter.rb @@ -5,7 +5,9 @@ module ActiveJob class QuAdapter class << self def enqueue(job, *args) - Qu::Payload.new(klass: JobWrapper, args: [job, *args], queue: job.queue_name).push + Qu::Payload.new(klass: JobWrapper, args: [job.name, *args]).tap do |payload| + payload.instance_variable_set(:@queue, job.queue_name) + end.push end def enqueue_at(job, timestamp, *args) @@ -14,8 +16,8 @@ module ActiveJob end class JobWrapper < Qu::Job - def initialize(job, *args) - @job = job + def initialize(job_name, *args) + @job = job_name.constantize @args = args end diff --git a/lib/active_job/queue_adapters/queue_classic_adapter.rb b/lib/active_job/queue_adapters/queue_classic_adapter.rb index db7189f076..c61e0e30db 100644 --- a/lib/active_job/queue_adapters/queue_classic_adapter.rb +++ b/lib/active_job/queue_adapters/queue_classic_adapter.rb @@ -5,7 +5,7 @@ module ActiveJob class QueueClassicAdapter class << self def enqueue(job, *args) - QC::Queue.new(job.queue_name).enqueue("#{JobWrapper.name}.perform", job, *args) + QC::Queue.new(job.queue_name).enqueue("#{JobWrapper.name}.perform", job.name, *args) end def enqueue_at(job, timestamp, *args) @@ -14,8 +14,8 @@ module ActiveJob end class JobWrapper - def self.perform(job, *args) - job.new.execute *args + def self.perform(job_name, *args) + job_name.constantize.new.execute *args end end end diff --git a/lib/active_job/queue_adapters/sneakers_adapter.rb b/lib/active_job/queue_adapters/sneakers_adapter.rb index f7da691935..094b128547 100644 --- a/lib/active_job/queue_adapters/sneakers_adapter.rb +++ b/lib/active_job/queue_adapters/sneakers_adapter.rb @@ -10,7 +10,7 @@ module ActiveJob def enqueue(job, *args) @monitor.synchronize do JobWrapper.from_queue job.queue_name - JobWrapper.enqueue [ job, *args ] + JobWrapper.enqueue ActiveSupport::JSON.encode([ job.name, *args ]) end end @@ -22,8 +22,10 @@ module ActiveJob class JobWrapper include Sneakers::Worker - def work(job, *args) - job.new.execute *args + def work(msg) + job_name, *args = ActiveSupport::JSON.decode(msg) + job_name.constantize.new.execute *args + ack! end end end