Files
twenty/packages/twenty-docs/l/ja/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.6 KiB
Plaintext

---
title: メッセージキュー
image: /images/user-guide/emails/emails_header.png
---
<Frame>
<img src="/images/user-guide/emails/emails_header.png" alt="Header" />
</Frame>
キューは非同期処理を実行するための手段を提供します。 それらは、登録時にウェルカムメールを送信するなどのバックグラウンドタスクを実行するために使用できます。
各ユースケースには `MessageQueueServiceBase` から拡張された独自のキュークラスが必要です。
現在のところ、キュードライバとして `bull-mq`[bull-mq](https://bullmq.io/) のみをサポートしています。
## 新しいキューを作成して使用する手順
1. Add a queue name for your new queue under enum `MESSAGE_QUEUES`.
2. 依存トークンとしてキュー名を持つキューのファクトリ実装を提供します。
3. Inject the queue that you created in the required module/service with the queue name as the dependency token.
4. トークンベースのインジェクションを用いたワーカークラスをプロデューサーと同様に追加します。
### 使用例
```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
});
}
}
```