Files
twenty/packages/twenty-docs/l/ca/developers/backend-development/queue.mdx
T
8cadd00d34 i18n - translations (#15799)
Created by Github action

---------

Co-authored-by: Crowdin Bot <support+bot@crowdin.com>
Co-authored-by: github-actions <github-actions@twenty.com>
2025-11-13 16:34:00 +01:00

48 lines
1.4 KiB
Plaintext

---
title: Cua de Missatges
image: /images/user-guide/emails/emails_header.png
---
<Frame>
<img src="/images/user-guide/emails/emails_header.png" alt="Header" />
</Frame>
Les cues faciliten la realització d'operacions asíncrones. Es poden utilitzar per realitzar tasques en segon pla com enviar un correu de benvinguda en registrar-se.
Cada cas d'ús tindrà la seva pròpia classe de cua estesa de `MessageQueueServiceBase`.
Actualment, només admetem `bull-mq`[bull-mq](https://bullmq.io/) com a controlador de cua.
## Passos per crear i utilitzar una nova cua
1. Add a queue name for your new queue under enum `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.
### Exemple d'ús
```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
});
}
}
```