Amazon Simple Queue Service, a.k.a. SQS, is a message queuing service that allows for building loosely coupled applications and services and features high availability and nearly unlimited throughput.
In this series of tutorial, we will create and configure an SQS queue and then develop .NET Core producer and consumer applications that send messages and receive messages, respectively.
Warning: some AWS services may have fees associated with them.
Putting It All Together
By now, we assume that you have completed the first three tutorials. If not, scroll up and have a look at the tutorials mentioned above.
First, let’s fire up the consumer. To run the consumer, we need to open a terminal in the directory where we created the consumer project and use the following command:
$ dotnet run
When the consumer runs you should see a message in the terminal that either reads “No Messages to process” or something like, “New Message for 2/19/2021 10:35:50 AM”. The first time that you run the application, you should get the former message. Then for each time that the application polls SQS you will get one of the messages, either “No Messages to process” when no message is available or something like, “New Message for 2/19/2021 10:35:50 AM” when a message is pulled from the queue.
Make sure you keep this terminal open and running.
Now, let’s open a new terminal, navigate to the directory where we created the producer app and run the producer with the following command:
$ dotnet run
When the producer runs, you will see a message like, “Message Sent: New Message for 2/19/2021 10:35:50 AM”. Now, take a look at the terminal that has the consumer running and you should see a corresponding message that reads something like, “New Message for 2/19/2021 10:35:50 AM”.
Congrats! You just finished creating an interapplication messaging solution!