Usage
Installation
To use the project, first build the project:
$ mvn package
Note
The Client and Worker apps need to be launch separately on different machines. However it is possible to launch the Worker on an EC2 instance
Using the Worker
EC2 Worker: a Java application (with one class that includes main method) that runs on an EC2 instance. It does the following tasks:
Create an AWS SQS queue named Inbox to receive messages from clients with
createQueue()functionCreate an AWS SQS queue named Outbox to send messages to clients with
createQueue()functionCheck for a message in the Inbox queue every 1 minute with
receiveMessagesfunctionIf there is a message, retrieve and delete the message from the queue with
deleteMessages(sqsClient, inbox, messages)functionRetrieve the file from the Amazon S3 whose bucket and name are indicated in the message body with
S3ControllerGetObjectclassCalculate (a) the Total Number of Sales, (b) the Total Amount Sold and (c) the Average Sold per country and per product with
CSVParserclassWrite the results in a file in the Amazon S3 with
S3ControllerPutObjectclassSend a response message in the Outbox queue to the client with the name of the incoming file and the output file containing the result with
sendMessages()fromSQSSendMEssagesClass
Using the Client
Client App : a Java application (with one class that includes main method) that is hosted on your local machine (not on the cloud). The Client App does the following steps:
Read the hourly sales file from the local hard-disk (For this project, the file sales-2021-01-02.csv)
Write the file into a bucket in the Amazon S3 with
S3ControllerCreateclass for creating the bucket andS3ControllerPutObjectfor writing the file.Send a message to the Inbox queue with the bucket and file names with
sendMessages()function fromSQSSndMessageclassWait until a response message is received with the results in the Outbox queue. The Client has to check the queue every 1 minute for messages with
retrieveMessage()function fromSQSRetrieveMessageclassOnce the message is received, retrieve the message content and delete the message from the Outbox queue with
deleteMessageClient()function fromSQSDeleteMEssageClientclassRead the file with the results from the Amazon S3 with
S3ControllerGetObjectclass