Active Job objects can be configured to work with different backend queuing frameworks. To specify a queue adapter to use:
ActiveJob::Base.queue_adapter = :inline
A list of supported adapters can be found in
Active Job objects can be defined by creating a class that inherits from the
ActiveJob::Base class. The only necessary method to implement is the “perform” method.
To define an Active Job object:
class ProcessPhotoJob < ActiveJob::Base def perform(photo) photo.watermark!('Rails') photo.rotate!(90.degrees) photo.resize_to_fit!(300, 300) photo.upload! end end
Records that are passed in are serialized/deserialized using Global ID. More information can be found in Arguments.
To enqueue a job to be performed as soon as the queueing system is free:
To enqueue a job to be processed at some point in the future:
More information can be found in
A job can also be processed immediately without sending to the queue:
DeserializationError- Error class for deserialization errors.
SerializationError- Error class for serialization errors.