
ActiveJob & Background Jobs
ActiveJob, Sidekiq, DelayedJob, job queues, perform_later, error handling, retry logic, GlobalID
1What is ActiveJob in Ruby on Rails?
What is ActiveJob in Ruby on Rails?
답변
ActiveJob is a built-in Rails framework that provides a unified interface for declaring jobs and running them on various queuing backends like Sidekiq, Resque, or DelayedJob. It allows switching backends without modifying job code, offering a standardized abstraction for asynchronous background processing.
2Which method should be used to execute a job asynchronously in ActiveJob?
Which method should be used to execute a job asynchronously in ActiveJob?
답변
The perform_later method enqueues the job for asynchronous execution by the configured queuing backend. The job is placed in a queue and will be processed later by a worker. Unlike perform_now which executes the job immediately and synchronously, perform_later frees the main thread and improves application responsiveness.
3What is the main difference between perform_later and perform_now in ActiveJob?
What is the main difference between perform_later and perform_now in ActiveJob?
답변
perform_later enqueues the job in a queue for later asynchronous execution by a worker, while perform_now executes the job immediately and synchronously in the current process. perform_now is useful for testing or when immediate execution is required, but it blocks the calling thread until the job completes.
How to define the default queue for an ActiveJob job?
What is GlobalID and what is its role in ActiveJob?
+17 면접 질문