It is some set of classes to interact with AWS SQS in different environments.
SQSClient
This program can run on our local laptop and send message to amazon-sqs queue. This has been tested in personal aws account. Below are the steps to make it run.
- We need to create a queue i.e mkd-test-queue in amazon-sqs.
- We need to get aws-access-key and aws-secret-key.
- We can run the program by passing aws-access-key and aws-secret-key as system properties using java -D option.
- It will send message to aws sqs queue defined in (1).
EC2SQSClient
This program is developed to run in EC2 instance and send message to aws-sqs queue.
- We need to create EC2 instance
- with appropriate role which has permission to access to sqs.
- with appropriate security group which can make https connection to sqs.
- We have used InstanceProfileCredentialsProvider. This credential provider gets credentials directly from instance metadata, so no need to provide explicitly.
- If EC2 is running behind proxy , we need to supply it in system properties e.g.
java -Dhttps.nonProxyHosts=169.254.169.254 -Dhttp.nonProxyHosts=169.254.169.254 -Dhttp.proxyHost= -Dhttp.proxyPort= -Dhttps.proxyHost= -Dhttps.proxyPort= -jar sqs-poc-1.0-SNAPSHOT-jar-with-dependencies.jar
Here value of nonProxyHosts is specific value i.e 169.254.169.254. The service which provides credentials is running here. InstanceProfileCredentialsProvider access this service.