Decoupling Applications
BACK

Decoupling Applications

Services used: SQS, SNS, EC2

Languages used: JSON

Objective: Improve availability and fault tolerance by decoupling microservices with messages sent to Amazon SQS queues and an Amazon SNS topic. Create a SNS topic and a SQS queue. Subscribe the SQS queue to the SNS topic. Create an additional SQS queue and subscribe it to the existing SNS topic.

Search for and open SNS

Type ImageNotification and click Next step.

Keep all default settings and scroll down to click Create topic.

Copy the ARN.

Search for and open SQS.

Click Create queue.

Name it ImageQueue.

Scroll down and select Advanced Access policy. Paste our sample JSON code at the end of Line 15.

Replace the placeholder text on Line 24 with the ARN we copied earlier. Copy the resource from Line 14 and paste it for the resource on Line 21. Scroll down and click Create queue.

Copy the ImageQueue URL.

Scroll down and click Subscribe to Amazon SNS topic.

Choose ImageNotification and click Save.

Search for and go to EC2.

Click Instances then select the Thumbnail UI instance check box. Copy the Public IPv4 Address.

In a new page type: http://PUBLIC_IP_ADDRESS/thumbnail and replace the Public IP with what we copied in the previous step. Paste the SQS URL for ImageQueue and click Submit.

Ensure that we receive the Success message. Close the browser.

Select the check box for the Loader UI instance and copy the Public IPv4 Address.

In a new page type: http://PUBLIC_IP_ADDRESS/loader and replace the Public IP with what we copied in the previous step. Paste the SNS topic ARN for ImageNotification and click Submit.

Click Start to Pull a satellite image.

Review the message received from SQS.

Search for and go to SQS.

Click Create queue.

Name it MessageQueue. Scroll down and click Create queue.

Copy the MessageQueue URL.

Scroll down and click Subscribe to Amazon SNS topic.

Choose ImageNotification and click Save.

Return to SNS Subscriptions and click the newest Subscription ID.

Ensure that the endpoint is the MessageQueue SQS. Success!