Ruby on Rails

ActiveJob & Background Jobs

ActiveJob, Sidekiq, DelayedJob, job queues, perform_later, error handling, retry logic, GlobalID

20 domande da colloquioยท
Mid-Level
1

What is ActiveJob in Ruby on Rails?

Risposta

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.

2

Which method should be used to execute a job asynchronously in ActiveJob?

Risposta

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.

3

What is the main difference between perform_later and perform_now in ActiveJob?

Risposta

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.

4

How to define the default queue for an ActiveJob job?

5

What is GlobalID and what is its role in ActiveJob?

+17 domande da colloquio

Padroneggia Ruby on Rails per il tuo prossimo colloquio

Accedi a tutte le domande, flashcards, test tecnici, esercizi di code review e simulatori di colloquio.

Inizia gratis