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, 기술 테스트, 코드 리뷰 연습, 면접 시뮬레이터에 접근하세요.

무료로 시작하기