Amazon SQS is a distributed queue system that enables web service applications to quickly and reliably queue messages that one component in the application generates to be consumed by another component. A queue is a temporary repository for messages that are awaiting processing.
You can find an introduction in http://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSGettingStartedGuide/Introduction.html
Here I will tell you my experience
1. Since your JMS server is in cloud, you do not need to install/start/stop any JMS server (I really hate to configure JMS settings in an application server). What you need is just run the Java application(You must have a valid Amazon Web Services developer account, and be signed up to use Amazon SQS.)
2. To view the messages your sample code created is easy.
1) Comment the “delete queue/message” part of the sample code
CreateQueueRequest createQueueRequest = new CreateQueueRequest(“MyQueue”);
String myQueueUrl = sqs.createQueue(createQueueRequest).getQueueUrl();
sqs.sendMessage(new SendMessageRequest(myQueueUrl, “This is my message text.”));
2) Switch to AWS Management view in your Eclipse, and you can see the queue, in this sample it is called MyQueue, in the following screen dump.
3. Receiving messages
ReceiveMessageRequest receiveMessageRequest = new ReceiveMessageRequest(myQueueUrl);
List messages = sqs.receiveMessage(receiveMessageRequest).getMessages();
for (Message message : messages) {
System.out.println(” Message”);
System.out.println(” MessageId: ” + message.getMessageId());
System.out.println(” ReceiptHandle: ” + message.getReceiptHandle());
System.out.println(” MD5OfBody: ” + message.getMD5OfBody());
System.out.println(” Body: ” + message.getBody());
for (Entry<string, string=””> entry : message.getAttributes().entrySet()) {
System.out.println(” Attribute”);
System.out.println(” Name: ” + entry.getKey());
System.out.println(” Value: ” + entry.getValue());
}
}
Thanks Luke for providing such an awesome post. I v learnt a lot from ur web blog. It is really helpful. Thanks