-
Notifications
You must be signed in to change notification settings - Fork 21.9k
Closed
Labels
Milestone
Description
queue_adapter is stored as a class variable. So when a child class overrides it, it also modifies the parent class as well. Therefore we cannot choose a different queue adapter at the job class level. Stuck with one global queue adapter until this is fixed. (Hopefully, being locked into one global queue adapter was not an intended feature)
ActiveJob::Base.queue_adapter == :inline #true
class ChildJobOne < ActiveJob::Base
self.queue_adapter= :delayed_job
end
Active::Base.queue_adapter == :delayed_job #the child job modified the parent's queue_adapter class variable
class ChildJobTwo < ActiveJob::Base
end
ChildJobTwo.queue_adapter == :delayed_job #new child job is also effected as well, no longer using the default :inline adapter
We can fix this by avoid directly using the class variable, instead should use mattr_writer to update the queue_adapter variable.
See https://github.com/rails/rails/blob/master/activejob/lib/active_job/queue_adapter.rb#L12