Point-to-Point Queue Pattern
What you'll learn: How to ensure exactly one consumer processes each message using point-to-point queues.
What Is Point-to-Point?
The point-to-point queue pattern ensures that each message sent to a queue is consumed by exactly one consumer, even if multiple consumers are listening. This contrasts with the publish-subscribe pattern (which you learned earlier) where one event reaches multiple subscribers.
Think of it like a task distribution system: When you add work orders to a shared inbox, only one worker picks up each order. If five workers are waiting, they don't all process the same order—each takes a unique one.
How It Works
- A producer sends a message to a queue
- The queue holds the message until a consumer is ready
- One consumer retrieves and processes the message
- The message is removed from the queue (or marked invisible during processing)
- Other consumers never see that message
When to Use Point-to-Point
This pattern is ideal when:
- You need load balancing across multiple workers
- Each task should be processed once and only once
- You want to scale consumers independently without duplicate processing
- Order matters (with FIFO queues) or doesn't (with standard queues)
Example Scenario
Imagine an image resizing service: users upload photos, and each upload creates a queue message. Five resize workers pull from the same queue. Photo #1 goes to Worker A, Photo #2 to Worker B, and so on. No photo gets resized twice.
This is exactly what you'd implement with AWS SQS Standard Queues or Azure Service Bus Queues—technologies you've already learned about.
Key Takeaway: Point-to-point queues guarantee one-to-one message delivery, enabling scalable task distribution where each message is processed by exactly one consumer.