Node.js / NestJS

Queues with Bull

Bull queues, processors, jobs, delayed jobs, priority, retries, events

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

What is Bull in the context of NestJS?

Câu trả lời

Bull is a Node.js library for managing persistent queues based on Redis. It allows executing background tasks asynchronously, handling priorities, retries, and delayed jobs. NestJS provides a @nestjs/bull module that natively integrates Bull into the framework's modular architecture, making it easy to create workers and manage heavy or long-running jobs.

2

What is the role of a processor in Bull?

Câu trả lời

A processor is a function that processes jobs from a queue. When a job is added to the queue, Bull automatically calls the corresponding processor to execute the business logic. The processor receives the job as a parameter and can access data via job.data. It can be synchronous or asynchronous and must return a value or Promise to signal job completion.

3

How to add a job to a Bull queue in NestJS?

Câu trả lời

To add a job, inject the queue via @InjectQueue('queueName') then use the add() method. This method takes optional parameters: a job name, data to process (payload), and options like delay, priority, attempts. The method returns a Promise containing the created job with its unique ID, allowing tracking or manipulation later.

4

What is the function of Redis in Bull's architecture?

5

How to define a delayed job in Bull?

+17 câu hỏi phỏng vấn

Nắm vững Node.js / NestJS 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í