You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/techniques/queues.md
+36-7Lines changed: 36 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -270,7 +270,6 @@ export class AudioConsumer extends WorkerHost {
270
270
271
271
This is covered in the [named processor](https://docs.bullmq.io/patterns/named-processor) section of the BullMQ documentation.
272
272
273
-
274
273
#### Request-scoped consumers
275
274
276
275
When a consumer is flagged as request-scoped (learn more about the injection scopes [here](/fundamentals/injection-scopes#provider-scope)), a new instance of the class will be created exclusively for each job. The instance will be garbage-collected after the job has completed.
@@ -320,15 +319,17 @@ You can see the complete list of events and their arguments as properties of Wor
320
319
QueueEvent listeners must use the `@QueueEventsListener(queue)` decorator and extend the `QueueEventsHost` class provided by `@nestjs/bullmq`. To listen for an event, use the `@OnQueueEvent(event)` decorator with the event you want to be handled. For example, to listen to the event emitted when a job enters the active state in the `audio` queue, use the following construct:
This construction works the same as `useClass` with one critical difference - `BullModule` will lookup imported modules to reuse an existing `ConfigService` instead of instantiating a new one.
452
453
454
+
Likewise, if you want to pass queue options asynchronously, use the `registerQueueAsync()` method, just keep in mind to specify the `name` attribute outside the factory function.
455
+
456
+
```typescript
457
+
BullModule.registerQueueAsync({
458
+
name: 'audio',
459
+
useFactory: () => ({
460
+
redis: {
461
+
host: 'localhost',
462
+
port: 6379,
463
+
},
464
+
}),
465
+
});
466
+
```
467
+
453
468
#### Bull installation
454
469
455
470
> warning **Note** If you decided to use BullMQ, skip this section and the following chapters.
0 commit comments