Skip to content

Commit

Permalink
docs(nestjs): add queue events listeners section
Browse files Browse the repository at this point in the history
  • Loading branch information
roggervalf committed Aug 17, 2023
1 parent 75dd80b commit d82fdcc
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/gitbook/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
* [Architecture](guide/architecture.md)
* [NestJs](guide/nestjs/README.md)
* [Producers](guide/nestjs/producers.md)
* [Queue Events Listeners](guide/nestjs/queue-events-listeners.md)
* [Going to production](guide/going-to-production.md)
* [Migration to newer versions](guide/migration-to-newer-versions.md)

Expand Down
49 changes: 49 additions & 0 deletions docs/gitbook/guide/nestjs/queue-events-listeners.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Queue Events Listeners

To register a QueueEvents instance, you need to use **QueueEventsListener** decorator:

```typescript
import {
QueueEventsListener,
QueueEventsHost,
OnQueueEvent,
} from '@nestjs/bullmq';

@QueueEventsListener('queueName')
export class TestQueueEvents extends QueueEventsHost {
@OnQueueEvent('completed')
onCompleted({
jobId,
}: {
jobId: string;
returnvalue: string;
prev?: string;
}) {
// do some stuff
}
}
```

And then register it as a provider:

```typescript
@Module({
imports: [
BullModule.registerQueue({
name: 'queueName',
connection: {
host: '0.0.0.0',
port: 6380,
},
}),
],
providers: [TestQueueEvents],
})
export class AppModule {}
```

## Read more:

- 💡 [Queues Technique](https://docs.nestjs.com/techniques/queues)
- 💡 [Register Queue API Reference](https://nestjs.bullmq.pro/classes/BullModule.html#registerQueue)
- 💡 [Queue Events Listener API Reference](https://api.docs.bullmq.io/interfaces/v4.QueueEventsListener.html)

0 comments on commit d82fdcc

Please sign in to comment.