This Go application integrates AWS SNS (Simple Notification Service) and SQS (Simple Queue Service). It allows users to input numbers via the console, which are then published to an SNS topic. This topic forwards the messages to an SQS queue. The server polls messages from the queue, accumulates their values, and prints the running total.
Before running this application, ensure you have:
- An AWS account with access to SNS and SQS services.
- AWS CLI configured with the necessary permissions to interact with SNS and SQS.
- Go installed on your system.
-
AWS Configuration: Make sure your AWS CLI is configured with credentials that have permission to publish to SNS topics and read from SQS queues. You can configure the AWS CLI by running
aws configure
. -
Create SNS Topic and SQS Queue: Use the AWS documentation to create an SNS topic and an SQS queue. Then, subscribe to the SQS queue to the SNS topic.
-
Install Dependencies: If your application has external dependencies, install them using Go's package manager by running
go mod tidy
.
Pass three command-line arguments when running the application:
-q
: The name of the SQS queue.-t
: The name of the SNS topic.-a
: The ARN of the SNS topic.
go run main.go -q YourQueueName -t YourTopicName -a YourTopicARN