Message queues 在组件之间启用异步通信 — producer 将消息发送到队列,consumer 稍后处理它们。它们分离组件、改进弹性、处理负载峰值,并启用后台处理。
Message queues 做什么
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.
为什么使用 message queues
✓ 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)
