Node.js / NestJS

Queues with Bull

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

20 คำถามสัมภาษณ์·
Mid-Level
1

What is Bull in the context of NestJS?

คำตอบ

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?

คำตอบ

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?

คำตอบ

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 คำถามสัมภาษณ์

เชี่ยวชาญ Node.js / NestJS สำหรับการสัมภาษณ์ครั้งถัดไป

เข้าถึงคำถามทั้งหมด flashcards แบบทดสอบเทคนิค แบบฝึกหัด code review และตัวจำลองสัมภาษณ์

เริ่มใช้ฟรี