Ruby on Rails

ActiveJob & Background Jobs

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

20 câu hỏi phỏng vấn·
Mid-Level
1

What is ActiveJob in Ruby on Rails?

Câu trả lời

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?

Câu trả lời

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?

Câu trả lời

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 câu hỏi phỏng vấn

Nắm vững Ruby on Rails cho lần phỏng vấn tiếp theo

Truy cập tất cả câu hỏi, flashcards, bài kiểm tra kỹ thuật, bài tập code review và mô phỏng phỏng vấn.

Bắt đầu miễn phí