Ruby on Rails

ActiveJob & Background Jobs

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

20 pertanyaan wawancaraยท
Mid-Level
1

What is ActiveJob in Ruby on Rails?

Jawaban

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?

Jawaban

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?

Jawaban

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 pertanyaan wawancara

Kuasai Ruby on Rails untuk wawancara berikutnya

Akses semua pertanyaan, flashcards, tes teknis, latihan code review dan simulator wawancara.

Mulai gratis