メッセージキューは、コンポーネント間の非同期通信を可能にします。プロデューサーがメッセージをキューに送信し、コンシューマーが後でそれらを処理します。これによりコンポーネントが疎結合になり、回復力が向上し、負荷スパイクに対応でき、バックグラウンド処理が可能になります。
メッセージキューの役割
A MESSAGE QUEUE sits between producers and consumers:
Producer → [QUEUE] → Consumer(s) process messages (asynchronously, at their own pace)
→ the producer doesn't wait for processing (sends and moves on)
→ messages are stored until processed (buffered)
→ ASYNCHRONOUS, decoupled communication.
メッセージキューを使う理由
✓ DECOUPLING → producers and consumers are independent (don't need to know each other or
be available at the same time) → flexible, resilient architecture
✓ LOAD LEVELING → the queue BUFFERS spikes → consumers process steadily (handle bursts
without overwhelming the system)
✓ ASYNC / background processing → offload slow work (emails, image processing, reports)
from the request path → fast responses
✓ RELIABILITY → messages persist until processed; retries on failure; not lost if a
consumer is down
✓ SCALABILITY → add more consumers to process faster (parallel processing)
