ExitMessage Queuing vs. Publish-Subscribe Messaging1 / 9
Explanationassociate9 steps · 4 exercises

One event, two kinds of delivery

Why workers sharing a queue compete to handle each message, while publish-subscribe gives each matching subscription its own delivery.

An image application reports uploads and metadata changes. Search indexing needs to see both. Thumbnail generation only needs uploads, and either of two identical thumbnail workers can do the job. That gives us two separate questions: Which applications need the event? and Which worker will do the work?

An Amazon SNS topic answers the first question by delivering to matching subscriptions. An Amazon SQS queue answers the second by holding work for workers to claim. The arrows show where messages travel, including messages returned when workers poll.

image eventuploads onlyall eventspolled jobspolled jobspolled jobs
Image event publisherAWS Lambda
Image events topicAmazon Simple Notification Service (Amazon SNS)
Shared thumbnail queueAmazon Simple Queue Service (Amazon SQS)
Search indexing queueAmazon Simple Queue Service (Amazon SQS)
Thumbnail worker AAmazon EC2
Thumbnail worker BAmazon EC2
Search indexing workerAmazon EC2

Stage 1 of 6: The publisher creates an event for each image upload or metadata change.

Next up: Trace a request on what you just read.

AWS architecture icons are the property of Amazon Web Services. BlowStack is not affiliated with or endorsed by AWS.