Amazon Simple Notification Service & Simple Queue Service

Dan Pelensky
2 min readAug 25, 2017

--

Over the last few weeks I have been working in the Amazon Web Services (AWS) environment to get familiar with it.

I’d previously built a Lambda and API for my Network Computer Player, and my next challenge was to update my Clojure Tic Tac Toe so that users could play, or spectate a Tic Tac Toe game. To implement this I needed to broadcast all the player’s moves to the network, and chose to use Amazon’s Simple Notification Service and Simple Queue Service.

Simple Notification Service (SNS)

AWS SNS is a Publish/Subscribe (Pub/Sub) messaging and notification service. A message is published to a topic once, and sent to every subscriber to the topic.

These messages can be sent to HTTP endpoints, email addresses, mobile phones as SMS, mobile apps as push notifications or to Amazon’s Simple Queue Service.

Simple Queue Service (SQS)

AWS SQS is a message queuing service, where messages are sent to a queue and delivered. You can send messages to a queue with a guarantee that they will be received at least once. Generally, once a message is received it is deleted off the queue.

High Level Mechanics

Every time a Player makes a move, it is published to a SNS Topic. Each message is then sent to every queue who subscribes to that topic.

App Flow

When the user launches the app they are given the choice of being a Player or a Spectator.

When a user chooses Player, every time they take a turn and when the game is over the board state is sent to a SNS topic. Once they game is over they can choose to play again.

When a user chooses Spectator, they get a Universally unique identifier (UUID), and a new queue is created with that UUID. The queue’s permissions are modified to accept messages from AWS SNS, and they are subscribed to the SNS topic. They are taken to a new screen, and as moves are played, and games finished, the moves automatically appear on their screen.

Demo

I have really enjoyed working in the AWS ecosystem, and look forward to learning more about it. There are over 70 services, and I feel like I’ve only just scratched the surface on the four that I’ve used.

--

--