{"id":14659,"date":"2013-06-25T10:00:35","date_gmt":"2013-06-25T07:00:35","guid":{"rendered":"http:\/\/www.javacodegeeks.com\/?p=14659"},"modified":"2013-06-25T10:40:39","modified_gmt":"2013-06-25T07:40:39","slug":"working-with-amazon-simple-queue-service-using-java","status":"publish","type":"post","link":"https:\/\/www.javacodegeeks.com\/2013\/06\/working-with-amazon-simple-queue-service-using-java.html","title":{"rendered":"Working with Amazon Simple Queue Service using java"},"content":{"rendered":"<p>Amazon Simple Queue Service or SQS is a highly scalable hosted messaging queue provided by Amazon Webservice stack. Amazon SQS can be used to completely decouple operations of different components within the system which otherwise exchange data to \u00a0perform independent tasks. Amazon SQS also helps us in saving the data which would be lost in case the application is down or if one of the component becomes unavailable.<\/p>\n<h2>Amazon SQS Features (Copied directly from amazon website)<\/h2>\n<ol>\n<li><strong>Redundant infrastructure<\/strong>\u2014Guarantees delivery of your messages at least once, highly concurrent access to messages, and high availability for sending and retrieving messages<\/li>\n<li><strong>Multiple writers and readers<\/strong>\u2014Multiple parts of your system can send or receive messages at the same time. SQS locks the message during processing, keeping other parts of your system from processing the message simultaneously.<\/li>\n<li><strong>Configurable settings per queue<\/strong>\u2014All of your queues don\u2019t have to be exactly alike. For example, one queue can be optimized for messages that require a longer processing time than others.<\/li>\n<li><strong>Variable message size<\/strong>\u2014Your messages can be up to 65536 bytes (64 KiB) in size. For even larger messages, you can store the contents of the message using the Amazon Simple Storage Service (Amazon S3) or Amazon SimpleDB and use Amazon SQS to hold a pointer to the Amazon S3 or Amazon SDB object. Alternately, you can split the larger message into smaller ones.<\/li>\n<li><strong>Access control<\/strong>\u2014You can control who can send messages to a queue, and who can receive messages from a queue<\/li>\n<li><strong>Delay Queues<\/strong>\u2014A delay queue is one which the user sets a default delay on a queue such that delivery of all messages enqueued will be postponed for that duration of time. You can set the delay value when you create a queue with CreateQueue, and you can update the value with SetQueueAttributes. If you update the value, the new value affects only messages enqueued after the update.<\/li>\n<\/ol>\n<p>With above knowledge in place let us try to use SQS for creating a simple photo\u00a0processing service.<\/p>\n<h2>Problem Defination for the tutorial<\/h2>\n<p>We will be creating a simple photo-processing application with following components.<\/p>\n<ol>\n<li><strong> Photo Uploader serivce<\/strong> \u2013 This is a webservice which allows users to upload a photo to the system. Once the photo is uploaded they are stored in a temporary storage. To keep it simple we will assume that user has already uploaded the photo and stored it in a predefined location.<\/li>\n<li><strong>AWSSimpleQueueServiceUtil<\/strong>\u00a0&#8211; This is a utility class which wraps a Amazon SQS client and performs basic CRUD operations on the SQS queue.<\/li>\n<li><strong>PhotoProcessingManager<\/strong> \u2013 Manages the entire show. It will invoke\u00a0AWSSimpleQueueServiceUtil \u00a0to send\/receive messages to SQS and invoke PhotoProcessor to process the photo and finally delete the message from the queue. \u00a0Mostly we should intend this class to act as Listener to the SQS but for simplicity we will just be using a Poll mechanism to pull the messages from SQS.<\/li>\n<li><strong>PhotoProcessor<\/strong> \u2013 Gets a photo message from SQS through\u00a0PhotoProcessingManager and generates a thumbnail.<\/li>\n<\/ol>\n<p>Before beginning it would be great if you go through video in the following link: <a title=\"http:\/\/docs.aws.amazon.com\/AWSSimpleQueueService\/latest\/SQSGettingStartedGuide\/Welcome.html. \" href=\"http:\/\/docs.aws.amazon.com\/AWSSimpleQueueService\/latest\/SQSGettingStartedGuide\/Welcome.html.\" target=\"_blank\">http:\/\/docs.aws.amazon.com\/AWSSimpleQueueService\/latest\/SQSGettingStartedGuide\/Welcome.html<\/a><\/p>\n<h2>Steps for getting started<\/h2>\n<ol>\n<li>Create a amazon account. You will need a credit card for that<\/li>\n<li>Log on to your console\u00a0<a title=\"console.aws.amazon.com\" href=\"console.aws.amazon.com\" target=\"_blank\">console.aws.amazon.com<\/a>.<\/li>\n<li>On console dashboard search for SQS and click on it. It will take you to your SQS home.<\/li>\n<li>Create a new SQS queue and name it PhotoQueue. Leave the rest of the setting as default. We can also create and delete a SQS queue dynamically but in this tutorial I have a pre-created queue which I will be using in my code.<\/li>\n<li>Now we have a queue and now we will create a simple java project in our\u00a0favorite\u00a0java editor and see how we can leverage this queue.<\/li>\n<li>Once you are done you need to download your security credentials. For this go to \u201cMy Account\u201d\/\u201dsecurity credentials\u201d. What we are after is access credentials. You will see that there are 3 types of access credentials one of them is \u201cAccess Keys\u201d. We need this to access and work on PhotoQueue we just created. We will create a new set of access keys and store the access key and secret key is a safe location.<\/li>\n<li>Now download the \u00a0sdk for java from here. <a title=\"http:\/\/aws.amazon.com\/sdkforjava\" href=\"http:\/\/aws.amazon.com\/sdkforjava\" target=\"_blank\">http:\/\/aws.amazon.com\/sdkforjava<\/a>. In lib folder of sdk copy the aws-java-sdk-1.3.33.jar to your project classpath.\n<p>Maven users can add following dependency in their POM<\/p>\n<pre class=\" brush:xml\">&lt;dependency&gt;\r\n\t&lt;groupId&gt;com.amazonaws&lt;\/groupId&gt;\r\n\t&lt;artifactId&gt;aws-java-sdk&lt;\/artifactId&gt;\r\n\t&lt;version&gt;1.3.33&lt;\/version&gt;\r\n&lt;\/dependency&gt;<\/pre>\n<p>Create a file called \u201cAwsCredentials.properties\u201d store this in your project. This file will contain following properties<div style=\"display:inline-block; margin: 15px 0;\"> <div id=\"adngin-JavaCodeGeeks_incontent_video-0\" style=\"display:inline-block;\"><\/div> <\/div><\/p>\n<pre class=\" brush:java\">accessKey =\r\nsecretKey =<\/pre>\n<p>The values of these properties are the access key you generated in the step 6.<\/li>\n<li>For photo processing I am using <strong><a title=\"imgscalr\" href=\"http:\/\/www.thebuzzmedia.com\/software\/imgscalr-java-image-scaling-library\/\" target=\"_blank\">imgscalr<\/a><\/strong>. It is a lightweight and awesome photo processing library in java for doing simple tasks like resize, rotate, crop etc. You can download the jar from\u00a0<a title=\"http:\/\/www.thebuzzmedia.com\/software\/imgscalr-java-image-scaling-library\/#download\" href=\"http:\/\/www.thebuzzmedia.com\/software\/imgscalr-java-image-scaling-library\/#download\">http:\/\/www.thebuzzmedia.com\/software\/imgscalr-java-image-scaling-library\/#download<\/a>. Maven users can add the following to their dependency list.\n<pre class=\" brush:xml\">&lt;dependency&gt;\r\n        &lt;groupId&gt;org.imgscalr&lt;\/groupId&gt;\r\n        &lt;artifactId&gt;imgscalr-lib&lt;\/artifactId&gt;\r\n        &lt;version&gt;4.2&lt;\/version&gt;\r\n        &lt;type&gt;jar&lt;\/type&gt;\r\n        &lt;scope&gt;compile&lt;\/scope&gt;\r\n &lt;\/dependency&gt;<\/pre>\n<\/li>\n<\/ol>\n<p>Now we are ready to rock and roll and get our hands dirty with some code.<\/p>\n<h4>AWSSimpleQueueServiceUtil.java<\/h4>\n<pre class=\" brush:java\">package com.aranin.adconnect.util.aws;\r\n\r\nimport com.amazonaws.auth.BasicAWSCredentials;\r\nimport com.amazonaws.services.sqs.AmazonSQS;\r\nimport com.amazonaws.services.sqs.AmazonSQSClient;\r\nimport com.amazonaws.services.sqs.model.*;\r\n\r\nimport java.io.FileInputStream;\r\nimport java.util.List;\r\nimport java.util.Properties;\r\n\r\n\/**\r\n * Created by IntelliJ IDEA.\r\n * User: Niraj Singh\r\n * Date: 3\/19\/13\r\n * Time: 10:44 AM\r\n * To change this template use File | Settings | File Templates.\r\n *\/\r\npublic class AWSSimpleQueueServiceUtil {\r\n    private BasicAWSCredentials credentials;\r\n    private AmazonSQS sqs;\r\n    private String simpleQueue = \"PhotoQueue\";\r\n    private static volatile  AWSSimpleQueueServiceUtil awssqsUtil = new AWSSimpleQueueServiceUtil();\r\n\r\n    \/**\r\n     * instantiates a AmazonSQSClient http:\/\/docs.aws.amazon.com\/AWSJavaSDK\/latest\/javadoc\/com\/amazonaws\/services\/sqs\/AmazonSQSClient.html\r\n     * Currently using  BasicAWSCredentials to pass on the credentials.\r\n     * For SQS you need to set your regions endpoint for sqs.\r\n     *\/\r\n    private   AWSSimpleQueueServiceUtil(){\r\n        try{\r\n            Properties properties = new Properties();\r\n            properties.load(new FileInputStream(\"D:\/samayik\/adkonnection\/src\/main\/resources\/AwsCredentials.properties\"));\r\n            this.credentials = new   BasicAWSCredentials(properties.getProperty(\"accessKey\"),\r\n                                                         properties.getProperty(\"secretKey\"));\r\n            this.simpleQueue = \"PhotoQueue\";\r\n\r\n            this.sqs = new AmazonSQSClient(this.credentials);\r\n            \/**\r\n             * My queue is in singapore region which has following endpoint for sqs\r\n             * https:\/\/sqs.ap-southeast-1.amazonaws.com\r\n             * you can find your endpoints here\r\n             * http:\/\/docs.aws.amazon.com\/general\/latest\/gr\/rande.html\r\n             *\r\n             * Overrides the default endpoint for this client (\"sqs.us-east-1.amazonaws.com\")\r\n             *\/\r\n            this.sqs.setEndpoint(\"https:\/\/sqs.ap-southeast-1.amazonaws.com\");\r\n            \/**\r\n               You can use this in your web app where    AwsCredentials.properties is stored in web-inf\/classes\r\n             *\/\r\n            \/\/AmazonSQS sqs = new AmazonSQSClient(new ClasspathPropertiesFileCredentialsProvider());\r\n\r\n        }catch(Exception e){\r\n            System.out.println(\"exception while creating awss3client : \" + e);\r\n        }\r\n    }\r\n\r\n    public static AWSSimpleQueueServiceUtil getInstance(){\r\n        return awssqsUtil;\r\n    }\r\n\r\n    public AmazonSQS getAWSSQSClient(){\r\n         return awssqsUtil.sqs;\r\n    }\r\n\r\n    public String getQueueName(){\r\n         return awssqsUtil.simpleQueue;\r\n    }\r\n\r\n    \/**\r\n     * Creates a queue in your region and returns the url of the queue\r\n     * @param queueName\r\n     * @return\r\n     *\/\r\n    public String createQueue(String queueName){\r\n        CreateQueueRequest createQueueRequest = new CreateQueueRequest(queueName);\r\n        String queueUrl = this.sqs.createQueue(createQueueRequest).getQueueUrl();\r\n        return queueUrl;\r\n    }\r\n\r\n    \/**\r\n     * returns the queueurl for for sqs queue if you pass in a name\r\n     * @param queueName\r\n     * @return\r\n     *\/\r\n    public String getQueueUrl(String queueName){\r\n        GetQueueUrlRequest getQueueUrlRequest = new GetQueueUrlRequest(queueName);\r\n        return this.sqs.getQueueUrl(getQueueUrlRequest).getQueueUrl();\r\n    }\r\n\r\n    \/**\r\n     * lists all your queue.\r\n     * @return\r\n     *\/\r\n    public ListQueuesResult listQueues(){\r\n       return this.sqs.listQueues();\r\n    }\r\n\r\n    \/**\r\n     * send a single message to your sqs queue\r\n     * @param queueUrl\r\n     * @param message\r\n     *\/\r\n    public void sendMessageToQueue(String queueUrl, String message){\r\n        SendMessageResult messageResult =  this.sqs.sendMessage(new SendMessageRequest(queueUrl, message));\r\n        System.out.println(messageResult.toString());\r\n    }\r\n\r\n    \/**\r\n     * gets messages from your queue\r\n     * @param queueUrl\r\n     * @return\r\n     *\/\r\n    public List&lt;Message&gt; getMessagesFromQueue(String queueUrl){\r\n       ReceiveMessageRequest receiveMessageRequest = new ReceiveMessageRequest(queueUrl);\r\n       List&lt;Message&gt; messages = sqs.receiveMessage(receiveMessageRequest).getMessages();\r\n       return messages;\r\n    }\r\n\r\n    \/**\r\n     * deletes a single message from your queue.\r\n     * @param queueUrl\r\n     * @param message\r\n     *\/\r\n    public void deleteMessageFromQueue(String queueUrl, Message message){\r\n        String messageRecieptHandle = message.getReceiptHandle();\r\n        System.out.println(\"message deleted : \" + message.getBody() + \".\" + message.getReceiptHandle());\r\n        sqs.deleteMessage(new DeleteMessageRequest(queueUrl, messageRecieptHandle));\r\n    }\r\n\r\n    public static void main(String[] args){\r\n\r\n    }\r\n\r\n}<\/pre>\n<p><strong>PhotoProcessor.java<\/strong><\/p>\n<pre class=\" brush:java\">package com.aranin.adconnect.util.aws;\r\n\r\nimport org.imgscalr.Scalr;\r\n\r\nimport javax.imageio.ImageIO;\r\nimport java.awt.image.BufferedImage;\r\nimport java.io.File;\r\n\r\n\/**\r\n * Created by IntelliJ IDEA.\r\n * User: Niraj Singh\r\n * Date: 3\/19\/13\r\n * Time: 12:32 PM\r\n * To change this template use File | Settings | File Templates.\r\n *\/\r\npublic class PhotoProcessor {\r\n\r\n    public static void  generateImage(String imagePath, String origName, String targetName, int scalabity){\r\n        String origImage =   null;\r\n        String targetImage = null;\r\n        File origFile = null;\r\n        BufferedImage buffImg = null;\r\n        File targetFile = null;\r\n        try{\r\n            origImage =   imagePath + \"\/\" + origName;\r\n            targetImage = imagePath + \"\/\" + targetName;\r\n            origFile = new File(origImage);\r\n            buffImg = ImageIO.read(origFile);\r\n            buffImg = Scalr.resize(buffImg, Scalr.Method.SPEED, scalabity);\r\n            targetFile = new File(targetImage);\r\n            ImageIO.write(buffImg, \"jpeg\", targetFile);\r\n\r\n        }catch (Exception e){\r\n            System.out.println(\"Exception in processing image : \" + e);\r\n        }finally {\r\n            buffImg = null;\r\n\r\n        }\r\n    }\r\n}<\/pre>\n<h4>PhotoFile.java<\/h4>\n<pre class=\" brush:java\">package com.aranin.adconnect.util.aws;\r\n\r\n\/**\r\n * Created by IntelliJ IDEA.\r\n * User: Niraj Singh\r\n * Date: 3\/19\/13\r\n * Time: 12:29 PM\r\n * To change this template use File | Settings | File Templates.\r\n *\/\r\npublic class PhotoFile {\r\n    private String origName;\r\n    private String targetName;\r\n    public String imagePath;\r\n\r\n    public String getOrigName() {\r\n        return origName;\r\n    }\r\n\r\n    public void setOrigName(String origName) {\r\n        this.origName = origName;\r\n    }\r\n\r\n    public String getTargetName() {\r\n        return targetName;\r\n    }\r\n\r\n    public void setTargetName(String targetName) {\r\n        this.targetName = targetName;\r\n    }\r\n\r\n    public String getImagePath() {\r\n        return imagePath;\r\n    }\r\n\r\n    public void setImagePath(String imagePath) {\r\n        this.imagePath = imagePath;\r\n    }\r\n\r\n    public String toString(){\r\n        return origName + \",\" +  targetName + \",\" + imagePath;\r\n    }\r\n}<\/pre>\n<h4>SQSPhotoManager.java<\/h4>\n<pre class=\" brush:java\">package com.aranin.adconnect.util.aws;\r\n\r\nimport com.amazonaws.services.sqs.model.Message;\r\n\r\nimport java.util.List;\r\nimport java.util.StringTokenizer;\r\n\r\n\/**\r\n * Created by IntelliJ IDEA.\r\n * User: Niraj Singh\r\n * Date: 3\/20\/13\r\n * Time: 11:38 AM\r\n * To change this template use File | Settings | File Templates.\r\n *\/\r\npublic class SQSPhotoManager implements Runnable{\r\n    private String queueUrl;\r\n    public static void main(String[] args){\r\n        AWSSimpleQueueServiceUtil awssqsUtil =   AWSSimpleQueueServiceUtil.getInstance();\r\n        \/**\r\n         * 1. get the url for your photo queue\r\n         *\/\r\n        String queueUrl  = awssqsUtil.getQueueUrl(awssqsUtil.getQueueName());\r\n        System.out.println(\"queueUrl : \" + queueUrl);\r\n\r\n        \/**\r\n         * 2. Add a photo to the queue to be processed\r\n         *\/\r\n\r\n        PhotoFile photo = new PhotoFile();\r\n        photo.setImagePath(\"C:\/Users\/Public\/Pictures\/Sample Pictures\");\r\n        photo.setOrigName(\"Tree.jpg\");\r\n        photo.setTargetName(\"Tree_thumb.jpg\");\r\n\r\n        \/**\r\n         * 3. set the photofile in queue for processing\r\n         *\/\r\n\r\n         awssqsUtil.sendMessageToQueue(queueUrl, photo.toString());\r\n\r\n        \/**\r\n         * get the messages from queue\r\n         *\/\r\n\r\n        Thread managerthread = new Thread(new SQSPhotoManager(queueUrl),\"T2\");\r\n        managerthread.start();\r\n\r\n    }\r\n\r\n    public SQSPhotoManager(String queueUrl){\r\n        this.queueUrl = queueUrl;\r\n    }\r\n\r\n    @Override\r\n    public void run() {\r\n        AWSSimpleQueueServiceUtil awssqsUtil =   AWSSimpleQueueServiceUtil.getInstance();\r\n        boolean flag = true;\r\n        while(flag){\r\n            List&lt;Message&gt; messages =  awssqsUtil.getMessagesFromQueue(this.queueUrl);\r\n            if(messages == null || messages.size() == 0){\r\n                try {\r\n                    Thread.sleep(1000);\r\n                } catch (InterruptedException e) {\r\n                    e.printStackTrace();  \/\/To change body of catch statement use File | Settings | File Templates.\r\n                }\r\n            }else{\r\n                flag = false;\r\n                for (Message message : messages) {\r\n                    String messagePhoto = message.getBody();\r\n                    System.out.println(\"photo to be processed : \" + messagePhoto);\r\n                    StringTokenizer photoTokenizer = new StringTokenizer(messagePhoto,\",\");\r\n                    String source = null;\r\n                    String target = null;\r\n                    String path = null;\r\n\r\n                    source = photoTokenizer.nextToken();\r\n                    target = photoTokenizer.nextToken();\r\n                    path = photoTokenizer.nextToken();\r\n                    System.out.println(\"source : \" + source);\r\n                    System.out.println(\"target : \" + target);\r\n                    System.out.println(\"path : \" + path);\r\n                    \/**\r\n                     * generate thumbmail within 150*150 container\r\n                     *\/\r\n                    PhotoProcessor.generateImage(path, source, target, 150);\r\n                }\r\n\r\n                \/**\r\n                * finally delete the message\r\n                *\/\r\n                for (Message message : messages) {\r\n                      awssqsUtil.deleteMessageFromQueue(this.queueUrl, message);\r\n                }\r\n\r\n            }\r\n        }\r\n    }\r\n}<\/pre>\n<p>This will form the core for your PhotoProcessor application using SQS. This code has a glaring drawback. It polls on the SQS using a thread, it would be great if you can create a listener in your code which can subscribe to your queue and take necessary action when new message arrives. That is indeed the subject of my next post. Till then feel free to bombard me with questions, together we can find answer to those.<br \/>\n&nbsp;<\/p>\n<div style=\"border: 1px solid #D8D8D8; background: #FAFAFA; width: 100%; padding-left: 5px;\"><b><i>Reference: <\/i><\/b><a href=\"http:\/\/weblog4j.com\/2013\/03\/20\/working-with-amazon-simple-queue-service-using-java\/\">Working with Amazon Simple Queue Service using java<\/a> from our <a href=\"http:\/\/www.javacodegeeks.com\/jcg\">JCG partner<\/a> Niraj Singh at the <a href=\"http:\/\/weblog4j.com\/\">Weblog4j<\/a> blog.<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Amazon Simple Queue Service or SQS is a highly scalable hosted messaging queue provided by Amazon Webservice stack. Amazon SQS can be used to completely decouple operations of different components within the system which otherwise exchange data to \u00a0perform independent tasks. Amazon SQS also helps us in saving the data which would be lost in &hellip;<\/p>\n","protected":false},"author":457,"featured_media":112,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[331],"class_list":["post-14659","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-enterprise-java","tag-amazon-aws"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Working with Amazon Simple Queue Service using java<\/title>\n<meta name=\"description\" content=\"Amazon Simple Queue Service or SQS is a highly scalable hosted messaging queue provided by Amazon Webservice stack. Amazon SQS can be used to completely\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.javacodegeeks.com\/2013\/06\/working-with-amazon-simple-queue-service-using-java.html\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Working with Amazon Simple Queue Service using java\" \/>\n<meta property=\"og:description\" content=\"Amazon Simple Queue Service or SQS is a highly scalable hosted messaging queue provided by Amazon Webservice stack. Amazon SQS can be used to completely\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.javacodegeeks.com\/2013\/06\/working-with-amazon-simple-queue-service-using-java.html\" \/>\n<meta property=\"og:site_name\" content=\"Java Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/javacodegeeks\" \/>\n<meta property=\"article:published_time\" content=\"2013-06-25T07:00:35+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2013-06-25T07:40:39+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/enterprise-java-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Niraj Singh\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:site\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Niraj Singh\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"10 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/06\\\/working-with-amazon-simple-queue-service-using-java.html#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/06\\\/working-with-amazon-simple-queue-service-using-java.html\"},\"author\":{\"name\":\"Niraj Singh\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/c1701df4314ba15d96a7e8ee21167280\"},\"headline\":\"Working with Amazon Simple Queue Service using java\",\"datePublished\":\"2013-06-25T07:00:35+00:00\",\"dateModified\":\"2013-06-25T07:40:39+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/06\\\/working-with-amazon-simple-queue-service-using-java.html\"},\"wordCount\":955,\"commentCount\":6,\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/06\\\/working-with-amazon-simple-queue-service-using-java.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/enterprise-java-logo.jpg\",\"keywords\":[\"Amazon AWS\"],\"articleSection\":[\"Enterprise Java\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/06\\\/working-with-amazon-simple-queue-service-using-java.html#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/06\\\/working-with-amazon-simple-queue-service-using-java.html\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/06\\\/working-with-amazon-simple-queue-service-using-java.html\",\"name\":\"Working with Amazon Simple Queue Service using java\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/06\\\/working-with-amazon-simple-queue-service-using-java.html#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/06\\\/working-with-amazon-simple-queue-service-using-java.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/enterprise-java-logo.jpg\",\"datePublished\":\"2013-06-25T07:00:35+00:00\",\"dateModified\":\"2013-06-25T07:40:39+00:00\",\"description\":\"Amazon Simple Queue Service or SQS is a highly scalable hosted messaging queue provided by Amazon Webservice stack. Amazon SQS can be used to completely\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/06\\\/working-with-amazon-simple-queue-service-using-java.html#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/06\\\/working-with-amazon-simple-queue-service-using-java.html\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/06\\\/working-with-amazon-simple-queue-service-using-java.html#primaryimage\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/enterprise-java-logo.jpg\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/enterprise-java-logo.jpg\",\"width\":150,\"height\":150,\"caption\":\"java-interview-questions-answers\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/06\\\/working-with-amazon-simple-queue-service-using-java.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Java\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/category\\\/java\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Enterprise Java\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/category\\\/java\\\/enterprise-java\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"Working with Amazon Simple Queue Service using java\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\",\"name\":\"Java Code Geeks\",\"description\":\"Java Developers Resource Center\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"alternateName\":\"JCG\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.javacodegeeks.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/exelixis-logo.png\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/javacodegeeks\",\"https:\\\/\\\/x.com\\\/javacodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/c1701df4314ba15d96a7e8ee21167280\",\"name\":\"Niraj Singh\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/147bedcf1582a3657c88a171d9057c1f6e52c9cc61db7ebff937824d89ed3995?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/147bedcf1582a3657c88a171d9057c1f6e52c9cc61db7ebff937824d89ed3995?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/147bedcf1582a3657c88a171d9057c1f6e52c9cc61db7ebff937824d89ed3995?s=96&d=mm&r=g\",\"caption\":\"Niraj Singh\"},\"sameAs\":[\"http:\\\/\\\/weblog4j.com\\\/\"],\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/author\\\/niraj-singh\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Working with Amazon Simple Queue Service using java","description":"Amazon Simple Queue Service or SQS is a highly scalable hosted messaging queue provided by Amazon Webservice stack. Amazon SQS can be used to completely","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.javacodegeeks.com\/2013\/06\/working-with-amazon-simple-queue-service-using-java.html","og_locale":"en_US","og_type":"article","og_title":"Working with Amazon Simple Queue Service using java","og_description":"Amazon Simple Queue Service or SQS is a highly scalable hosted messaging queue provided by Amazon Webservice stack. Amazon SQS can be used to completely","og_url":"https:\/\/www.javacodegeeks.com\/2013\/06\/working-with-amazon-simple-queue-service-using-java.html","og_site_name":"Java Code Geeks","article_publisher":"https:\/\/www.facebook.com\/javacodegeeks","article_published_time":"2013-06-25T07:00:35+00:00","article_modified_time":"2013-06-25T07:40:39+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/enterprise-java-logo.jpg","type":"image\/jpeg"}],"author":"Niraj Singh","twitter_card":"summary_large_image","twitter_creator":"@javacodegeeks","twitter_site":"@javacodegeeks","twitter_misc":{"Written by":"Niraj Singh","Est. reading time":"10 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.javacodegeeks.com\/2013\/06\/working-with-amazon-simple-queue-service-using-java.html#article","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/2013\/06\/working-with-amazon-simple-queue-service-using-java.html"},"author":{"name":"Niraj Singh","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/c1701df4314ba15d96a7e8ee21167280"},"headline":"Working with Amazon Simple Queue Service using java","datePublished":"2013-06-25T07:00:35+00:00","dateModified":"2013-06-25T07:40:39+00:00","mainEntityOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2013\/06\/working-with-amazon-simple-queue-service-using-java.html"},"wordCount":955,"commentCount":6,"publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2013\/06\/working-with-amazon-simple-queue-service-using-java.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/enterprise-java-logo.jpg","keywords":["Amazon AWS"],"articleSection":["Enterprise Java"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.javacodegeeks.com\/2013\/06\/working-with-amazon-simple-queue-service-using-java.html#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.javacodegeeks.com\/2013\/06\/working-with-amazon-simple-queue-service-using-java.html","url":"https:\/\/www.javacodegeeks.com\/2013\/06\/working-with-amazon-simple-queue-service-using-java.html","name":"Working with Amazon Simple Queue Service using java","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2013\/06\/working-with-amazon-simple-queue-service-using-java.html#primaryimage"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2013\/06\/working-with-amazon-simple-queue-service-using-java.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/enterprise-java-logo.jpg","datePublished":"2013-06-25T07:00:35+00:00","dateModified":"2013-06-25T07:40:39+00:00","description":"Amazon Simple Queue Service or SQS is a highly scalable hosted messaging queue provided by Amazon Webservice stack. Amazon SQS can be used to completely","breadcrumb":{"@id":"https:\/\/www.javacodegeeks.com\/2013\/06\/working-with-amazon-simple-queue-service-using-java.html#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.javacodegeeks.com\/2013\/06\/working-with-amazon-simple-queue-service-using-java.html"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/2013\/06\/working-with-amazon-simple-queue-service-using-java.html#primaryimage","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/enterprise-java-logo.jpg","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/enterprise-java-logo.jpg","width":150,"height":150,"caption":"java-interview-questions-answers"},{"@type":"BreadcrumbList","@id":"https:\/\/www.javacodegeeks.com\/2013\/06\/working-with-amazon-simple-queue-service-using-java.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.javacodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"Java","item":"https:\/\/www.javacodegeeks.com\/category\/java"},{"@type":"ListItem","position":3,"name":"Enterprise Java","item":"https:\/\/www.javacodegeeks.com\/category\/java\/enterprise-java"},{"@type":"ListItem","position":4,"name":"Working with Amazon Simple Queue Service using java"}]},{"@type":"WebSite","@id":"https:\/\/www.javacodegeeks.com\/#website","url":"https:\/\/www.javacodegeeks.com\/","name":"Java Code Geeks","description":"Java Developers Resource Center","publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"alternateName":"JCG","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.javacodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.javacodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/www.javacodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/javacodegeeks","https:\/\/x.com\/javacodegeeks"]},{"@type":"Person","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/c1701df4314ba15d96a7e8ee21167280","name":"Niraj Singh","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/147bedcf1582a3657c88a171d9057c1f6e52c9cc61db7ebff937824d89ed3995?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/147bedcf1582a3657c88a171d9057c1f6e52c9cc61db7ebff937824d89ed3995?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/147bedcf1582a3657c88a171d9057c1f6e52c9cc61db7ebff937824d89ed3995?s=96&d=mm&r=g","caption":"Niraj Singh"},"sameAs":["http:\/\/weblog4j.com\/"],"url":"https:\/\/www.javacodegeeks.com\/author\/niraj-singh"}]}},"_links":{"self":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/14659","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/users\/457"}],"replies":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/comments?post=14659"}],"version-history":[{"count":0,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/14659\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media\/112"}],"wp:attachment":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media?parent=14659"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/categories?post=14659"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/tags?post=14659"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}