---
title: Viestijono
image: /images/user-guide/emails/emails_header.png
---
Jonot mahdollistavat asynkronisten toimintojen suorittamisen. Niitä voidaan käyttää taustatehtävien suorittamiseen, kuten tervetuloviestin lähettämiseen rekisteröityessä.
Each use case will have its own queue class extended from `MessageQueueServiceBase`.
Tällä hetkellä tuemme vain `bull-mq`[bull-mq](https://bullmq.io/) jono-ohjaimena.
## Vaiheet uuden jonon luomiseen ja käyttöön
1. Lisää jonon nimi uudelle jonolle luokkaan `MESSAGE_QUEUES`.
2. Provide the factory implementation of the queue with the queue name as the dependency token.
3. Inject the queue that you created in the required module/service with the queue name as the dependency token.
4. Add worker class with token based injection just like producer.
### Esimerkkikäyttö
```ts
class Resolver {
constructor(@Inject(MESSAGE_QUEUES.custom) private queue: MessageQueueService) {}
async onSomeAction() {
//business logic
await this.queue.add(someData);
}
}
//async worker
class CustomWorker {
constructor(@Inject(MESSAGE_QUEUES.custom) private queue: MessageQueueService) {
this.initWorker();
}
async initWorker() {
await this.queue.work(async ({ id, data }) => {
//worker logic
});
}
}
```