{"id":112298,"date":"2021-12-28T07:00:00","date_gmt":"2021-12-28T05:00:00","guid":{"rendered":"https:\/\/www.javacodegeeks.com\/?p=112298"},"modified":"2021-12-10T14:56:41","modified_gmt":"2021-12-10T12:56:41","slug":"localstack-sqs-node-js-example","status":"publish","type":"post","link":"https:\/\/www.javacodegeeks.com\/localstack-sqs-node-js-example.html","title":{"rendered":"LocalStack SQS Node.js Example"},"content":{"rendered":"<p>Hello. In this tutorial, we will interact with Amazon AWS SQS (simple queue service) to create a Node.js app with the help of a popular emulator known as LocalStack.<\/p>\n<h2>1. Introduction<\/h2>\n<p><strong>Localstack<\/strong> is an aws cloud service emulator that runs in a single container and allows us to run the aws applications on our local machines without connecting to a remote cloud provider. This tool helps to speed up and simplify the testing and development workflow. To work with localstack we will use docker so that we have the setup ready within minutes and without any dependency. If someone needs to go through the Docker installation, please watch <a href=\"https:\/\/www.youtube.com\/watch?v=R-ZMkGvh-9Y\" target=\"_blank\" rel=\"noopener\">this<\/a> video.<\/p>\n<h3>1.1 Setting up Node.js<\/h3>\n<p>To set up <strong>Node.js<\/strong> on windows you will need to download the installer from <a href=\"https:\/\/nodejs.org\/en\/download\/\" target=\"_blank\" rel=\"noopener\">this<\/a> link. Click on the installer (also include the NPM package manager) for your platform and run the installer to start with the Node.js setup wizard. Follow the wizard steps and click on Finish when it is done. If everything goes well you can navigate to the command prompt to verify if the installation was successful as shown in Fig. 1.<\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><a href=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2021\/12\/node-npm-installation-img1.jpg\"><img decoding=\"async\" width=\"480\" height=\"91\" src=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2021\/12\/node-npm-installation-img1.jpg\" alt=\"LocalStack SQS Node.js - npm installation\" class=\"wp-image-112299\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2021\/12\/node-npm-installation-img1.jpg 480w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2021\/12\/node-npm-installation-img1-300x57.jpg 300w\" sizes=\"(max-width: 480px) 100vw, 480px\" \/><\/a><figcaption>Fig. 1: Verifying node and npm installation<\/figcaption><\/figure>\n<\/div>\n<h3>1.2 Setting up LocalStack<\/h3>\n<p>To set up the <a href=\"https:\/\/github.com\/localstack\/localstack\" target=\"_blank\" rel=\"noopener\">localstack<\/a> on our machine we will write a simple docker-compose file and execute the docker-compose commands to quickly start\/stop the container. Add the below code the yml file to have the container up and running in minutes \u2013<\/p>\n<p><span style=\"text-decoration: underline;\"><em>docker-compose.yml<\/em><\/span><\/p>\n<pre class=\"brush:plain;\">services:\n  localstack:\n    environment:\n      - AWS_DEFAULT_REGION=ap-southeast-1\n      - EDGE_PORT=4566\n      - SERVICES=sqs\n    image: \"localstack\/localstack:latest\"\n    ports:\n      - \"4566:4566\"\n    container_name: docker-localstack\n    volumes:\n      - \"${TMPDIR:-\/tmp\/localstack}:\/tmp\/localstack\"\n      - \"\/var\/run\/docker.sock:\/var\/run\/docker.sock\"\nversion: \"3.0\"\n<\/pre>\n<p>You\u2019re free to change the details in the above yml file as per your requirements. For this tutorial, I am keeping some of the details are default.<\/p>\n<h3>1.3 Start\/Stop the container<\/h3>\n<p>To start the localstack container we will execute the <code>docker-compose<\/code> command in the terminal window. Open a new terminal, navigate to the path containing the yml file and execute the below command.<\/p>\n<p><span style=\"text-decoration: underline;\"><em>Start the container<\/em><\/span><\/p>\n<pre class=\"brush:plain;\">-- pull the image, create and start the container --\ndocker compose up -d\n<\/pre>\n<p>The above command will start the container on port \u2013 <code>4566<\/code> in daemon mode. If you will be doing this activity for the first time then the Docker tool will first pull the image from the hub repository. You can hit the health endpoint in the browser to confirm that the localstack container is up and running successfully.<\/p>\n<p><span style=\"text-decoration: underline;\"><em>Localstack health check endpoint<\/em><\/span><\/p>\n<pre class=\"brush:plain;\">-- to check whether the localstack is up and running --\nhttp:\/\/localhost:4566\/health\n<\/pre>\n<p>Once you are done with the tutorial use the below command to stop and remove the running localstack container.<\/p>\n<p><span style=\"text-decoration: underline;\"><em>Stop and remove the container<\/em><\/span><\/p>\n<pre class=\"brush:plain;\">-- stop and remove the container \u2013\ndocker compose down\n<\/pre>\n<h2>2. LocalStack SQS Node.js Example<\/h2>\n<p>To set up the application, we will need to navigate to a path where our project will reside. For programming stuff, I am using <a href=\"https:\/\/code.visualstudio.com\/\" target=\"_blank\" rel=\"noopener\">Visual Studio Code<\/a> as my preferred IDE. You&#8217;re free to choose the IDE of your choice.<\/p>\n<h3>2.1 Setting up the implementation<\/h3>\n<p>Let us write the different files which will be required for practical learning.<\/p>\n<h4>2.1.1 Setting up dependencies<\/h4>\n<p>Navigate to the project directory and run <code>npm init -y<\/code> to create a <code>package.json<\/code> file. This <a href=\"https:\/\/docs.npmjs.com\/creating-a-package-json-file\" target=\"_blank\" rel=\"noopener\">file<\/a> holds the metadata relevant to the project and is used for managing the project dependencies, script, version, etc. Add the following code to the file wherein we will specify the required dependencies.<\/p>\n<p><span style=\"text-decoration: underline;\"><em>package.json<\/em><\/span><\/p>\n<pre class=\"brush:json;\">{\n  \"name\": \"localstack-sqs\",\n  \"version\": \"1.0.0\",\n  \"description\": \"localstack sqs\",\n  \"main\": \"index.js\",\n  \"scripts\": {\n    \"test\": \"echo \\\"Error: no test specified\\\" &amp;&amp; exit 1\",\n    \"dev\": \"nodemon index.js\"\n  },\n  \"keywords\": [\n    \"localstack sqs\",\n    \"nodejs\",\n    \"expressjs\"\n  ],\n  \"author\": \"javacodegeeks\",\n  \"license\": \"ISC\",\n  \"dependencies\": {\n    \"aws-sdk\": \"^2.1043.0\",\n    \"express\": \"^4.17.1\",\n    \"underscore\": \"^1.13.1\"\n  },\n  \"devDependencies\": {\n    \"nodemon\": \"^2.0.15\"\n  }\n}\n<\/pre>\n<p>To download the dependencies navigate to the directory path containing the file and use the <code>npm install<\/code> command. If everything goes well the dependencies will be loaded inside the <code>node_modules<\/code> folder and you are good to go with the further steps.<div style=\"display:inline-block; margin: 15px 0;\"> <div id=\"adngin-JavaCodeGeeks_incontent_video-0\" style=\"display:inline-block;\"><\/div> <\/div><\/p>\n<h4>2.1.2 Creating an environment config<\/h4>\n<p>Once the localstack is up and running we will be creating the environment configuration file required for this tutorial. Add the below code to the file present in the <code>config<\/code> folder. The file contains the localstack service endpoint and other required information for this tutorial.<\/p>\n<p><span style=\"text-decoration: underline;\"><em>env.js<\/em><\/span><\/p>\n<pre class=\"brush:js;\">const env = {\n  REGION: \"ap-southeast-1\", \/\/ should match the one given in the docker-compose.yml file\n  ACCOUNT_ID: \"000000000000\", \/\/ represents the dummy aws account id for localstack\n  IAM: {\n    ACCESS_KEY_ID: \"na\",\n    SECRET_ACCESS_KEY: \"na\"\n  },\n  SERVICE_ENDPOINT: \"http:\/\/localhost:4566\", \/\/ represents the service point for localstack\n  QUEUE_NAME: \"geek\" \/\/ queue name used in this tutorial for implementation\n};\n\nmodule.exports = env;\n<\/pre>\n<h4>2.1.3 Creating a request handler class<\/h4>\n<p>Create a request handler class that will be responsible to handle the incoming requests from the client. The file will also contain the information about the sqs service object creation. Add the below code to the file present in the <code>handler<\/code> folder.<\/p>\n<p><span style=\"text-decoration: underline;\"><em>requests.js<\/em><\/span><\/p>\n<pre class=\"brush:js;\">const _ = require(\"underscore\");\n\nconst env = require(\"..\/config\/env\");\n\n\/\/ configuring local-stack aws\nconst AWS = require(\"aws-sdk\");\nAWS.config.update({\n  region: env.REGION\n});\n\n\/\/ create an sqs service object\nconst sqs = new AWS.SQS({\n  endpoint: env.SERVICE_ENDPOINT,\n  accessKeyId: env.IAM.ACCESS_KEY_ID,\n  secretAccessKey: env.IAM.SECRET_ACCESS_KEY,\n  region: env.REGION\n});\n\n\/\/ handler methods\n\n\/\/ method1 - to get sqs config status\nconst getConfigurationStatus = (req, res) =&gt; {\n  console.log(\"fetching configuration status\");\n  res.status(200).json({\n    status: \"ok\",\n    data: sqs\n  });\n};\n\n\/\/ method2 - to list all queues\nconst listQueues = (req, res) =&gt; {\n  console.log(\"fetching all queues\");\n  sqs.listQueues({}, (err, data) =&gt; {\n    if (err) {\n      res.status(500).json({\n        status: \"internal server error\",\n        error: err\n      });\n    } else {\n      res.status(200).json({\n        status: \"ok\",\n        urls: data.QueueUrls\n      });\n    }\n  });\n};\n\n\/\/ method3 - to create a new sqs queue\nconst createQueue = (req, res) =&gt; {\n  let createParams = {\n    QueueName: env.QUEUE_NAME, \/\/ in real example client should provide queue name\n    Attributes: {\n      DelaySeconds: \"60\",\n      MessageRetentionPeriod: \"86400\"\n    }\n  };\n  console.log(createParams);\n\n  sqs.createQueue(createParams, (err, data) =&gt; {\n    if (err) {\n      res.status(500).json({\n        status: \"internal server error\",\n        error: err\n      });\n    } else {\n      res.status(201).json({\n        status: \"created\",\n        name: data.QueueName,\n        message: \"queue created successfully\"\n      });\n    }\n  });\n};\n\n\/\/ method4 - to purge the given sqs queue\nconst purgeQueue = (req, res) =&gt; {\n  let queueName = req.query.name;\n  if (_.isEmpty(queueName)) {\n    res.status(400).json({\n      status: \"bad request\",\n      message: \"queue name cannot be empty\"\n    });\n  } else {\n    console.log(\"purging queue = \" + queueName);\n\n    let purgeParams = {\n      QueueUrl: env.SERVICE_ENDPOINT + \"\/\" + env.ACCOUNT_ID + \"\/\" + queueName\n    };\n    console.log(purgeParams);\n\n    sqs.purgeQueue(purgeParams, (err, data) =&gt; {\n      if (err) {\n        res.status(500).json({\n          status: \"500\",\n          err: err\n        });\n      } else {\n        res.status(200).json({\n          status: \"ok\",\n          data: \"queue purged\"\n        });\n      }\n    });\n  }\n};\n\n\/\/ method5 - to publish the message to the sqs queue\nconst publishMsg = (req, res) =&gt; {\n  \/\/todo - add empty queue name validation in the request body\n\n  let msg = {\n    id: req.body[\"id\"],\n    name: req.body[\"name\"],\n    email: req.body[\"email\"],\n    phone: req.body[\"phone\"]\n  };\n\n  let msgParams = {\n    QueueUrl:\n      env.SERVICE_ENDPOINT + \"\/\" + env.ACCOUNT_ID + \"\/\" + req.body[\"queueName\"], \/\/ queueName will never be empty\n    MessageBody: JSON.stringify(msg)\n  };\n  console.log(msgParams);\n\n  sqs.sendMessage(msgParams, (err, data) =&gt; {\n    if (err) {\n      res.status(500).json({\n        status: \"internal server error\",\n        error: err\n      });\n    } else {\n      res.status(202).json({\n        status: \"accepted\",\n        messageId: data.MessageId,\n        message: \"sent to queue\"\n      });\n    }\n  });\n};\n\n\/\/ method6 - to receive the message from the sqs queue\nconst receiveMsg = (req, res) =&gt; {\n  let queueName = req.query.name;\n  if (_.isEmpty(queueName)) {\n    res.status(400).json({\n      status: \"bad request\",\n      message: \"queue name cannot be empty\"\n    });\n  } else {\n    console.log(\"Fetching messages from queue = \" + queueName);\n\n    let receiveParams = {\n      QueueUrl: env.SERVICE_ENDPOINT + \"\/\" + env.ACCOUNT_ID + \"\/\" + queueName,\n      MessageAttributeNames: [\"All\"]\n    };\n    console.log(receiveParams);\n\n    sqs.receiveMessage(receiveParams, (err, data) =&gt; {\n      if (err) {\n        res.status(500).json({\n          status: \"internal server error\",\n          error: err\n        });\n      } else {\n        if (!data.Messages) {\n          res.status(200).json({\n            status: \"ok\",\n            data: \"no message in the queue\"\n          });\n        } else {\n          let items = [];\n          _.each(data.Messages, function (message) {\n            let ele = {\n              id: message.MessageId,\n              receiptHandle: message.ReceiptHandle,\n              data: JSON.parse(message.Body)\n            };\n            items.push(ele);\n          });\n          res.status(200).json({\n            status: \"ok\",\n            messages: items\n          });\n        }\n      }\n    });\n  }\n};\n\n\/\/ method7 - to delete the message from the sqs queue\nconst deleteMsg = (req, res) =&gt; {\n  let id = req.query.id;\n  let queueName = req.query.name;\n  if (_.isEmpty(id) || _.isEmpty(queueName)) {\n    res.status(400).json({\n      status: \"bad request\",\n      message: \"receipt handle id or queue name cannot be empty\"\n    });\n  } else {\n    console.log(\"Deleting message id = \" + id + \" from queue\");\n\n    let deleteParams = {\n      QueueUrl: env.SERVICE_ENDPOINT + \"\/\" + env.ACCOUNT_ID + \"\/\" + queueName,\n      ReceiptHandle: id\n    };\n    console.log(deleteParams);\n\n    sqs.deleteMessage(deleteParams, (err, data) =&gt; {\n      if (err) {\n        res.status(500).json({\n          status: \"internal server error\",\n          error: err\n        });\n      } else {\n        res.status(202).json({\n          status: \"accepted\",\n          message: \"message deleted from queue\"\n        });\n      }\n    });\n  }\n};\n\nmodule.exports = {\n  getConfigurationStatus,\n  listQueues,\n  createQueue,\n  purgeQueue,\n  publishMsg,\n  receiveMsg,\n  deleteMsg\n};\n<\/pre>\n<h4>2.1.4 Creating a routing class<\/h4>\n<p>Create a routing class that will be responsible to map the incoming requests from the client with the handler method. Add the below code to the file present in the <code>routes<\/code> folder.<\/p>\n<p><span style=\"text-decoration: underline;\"><em>routes.js<\/em><\/span><\/p>\n<pre class=\"brush:js;\">const express = require(\"express\");\nconst router = express.Router();\n\nconst {\n  getConfigurationStatus,\n  listQueues,\n  createQueue,\n  publishMsg,\n  receiveMsg,\n  deleteMsg,\n  purgeQueue\n} = require(\"..\/handler\/requests\");\n\n\/\/ get sqs config status\n\/\/ endpoint - http:\/\/localhost:6001\/status\nrouter.get(\"\/status\", getConfigurationStatus);\n\n\/\/ list sqs queues\n\/\/ endpoint - http:\/\/localhost:6001\/list\nrouter.get(\"\/list\", listQueues);\n\n\/\/ create a sqs queue\n\/\/ endpoint - http:\/\/localhost:6001\/create\nrouter.post(\"\/create\", createQueue);\n\n\/\/ purge a sqs queue\n\/\/ endpoint - http:\/\/localhost:6001\/purge\nrouter.delete(\"\/purge\", purgeQueue);\n\n\/\/ send message to sqs queue\n\/\/ endpoint - http:\/\/localhost:6001\/send\nrouter.post(\"\/send\", publishMsg);\n\n\/\/ receive message from sqs queue\n\/\/ endpoint - http:\/\/localhost:6001\/receive\nrouter.get(\"\/receive\", receiveMsg);\n\n\/\/ delete message from sqs queue\n\/\/ endpoint - http:\/\/localhost:6001\/delete\nrouter.delete(\"\/delete\", deleteMsg);\n\nmodule.exports = {\n  appRoutes: router\n};\n<\/pre>\n<h4>2.1.5 Creating an index file<\/h4>\n<p>Create an index file that will be acting as the entry point for the application.<\/p>\n<p><span style=\"text-decoration: underline;\"><em>index.js<\/em><\/span><\/p>\n<pre class=\"brush:js;\">\/\/ application\nconst express = require(\"express\");\n\nconst app = express();\napp.use(express.json());\n\n\/\/ application routes\nconst routes = require(\".\/routes\/routes\");\napp.use(\"\/\", routes.appRoutes);\n\n\/\/ start application\nconst port = process.env.PORT || 6001;\napp.listen(port, () =&gt; {\n  console.log(`Service endpoint = http:\/\/localhost:${port}`);\n});\n<\/pre>\n<h2>3. Run the Application<\/h2>\n<p>To run the application navigate to the project directory and enter the following command as shown below.<\/p>\n<p><span style=\"text-decoration: underline;\"><em>Command<\/em><\/span><\/p>\n<pre class=\"brush:plain;\">$ nodemon\n<\/pre>\n<p>If everything goes well the application will be started successfully on port &#8211; <code>6001<\/code> as shown in Fig. 2.<\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><a href=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2021\/12\/localhost-sqs-runguide-img1.jpg\"><img decoding=\"async\" width=\"545\" height=\"130\" src=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2021\/12\/localhost-sqs-runguide-img1.jpg\" alt=\"LocalStack SQS Node.js - app run\" class=\"wp-image-112300\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2021\/12\/localhost-sqs-runguide-img1.jpg 545w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2021\/12\/localhost-sqs-runguide-img1-300x72.jpg 300w\" sizes=\"(max-width: 545px) 100vw, 545px\" \/><\/a><figcaption>Fig. 2: Application run<\/figcaption><\/figure>\n<\/div>\n<h2>4. Demo<\/h2>\n<p>You are free to use <a href=\"https:\/\/www.getpostman.com\/\" target=\"_blank\" rel=\"noopener\">postman<\/a> or any other tool of your choice to make the HTTP request to the application endpoints. Download the endpoints collection from the downloads section for an easy setup.<\/p>\n<p><span style=\"text-decoration: underline;\"><em>Application endpoints<\/em><\/span><\/p>\n<pre class=\"brush:plain;\">\/\/ get sqs config status\n\/\/ http get endpoint - http:\/\/localhost:6001\/status\n\n\/\/ list sqs queues\n\/\/ http get endpoint - http:\/\/localhost:6001\/list\n\n\/\/ create a sqs queue\n\/\/ http post endpoint - http:\/\/localhost:6001\/create\n\n\/\/ purge a sqs queue\n\/\/ http delete endpoint - http:\/\/localhost:6001\/purge\n\n\/\/ send message to sqs queue\n\/\/ http post endpoint - http:\/\/localhost:6001\/send\n\n\/\/ receive message from sqs queue\n\/\/ http get endpoint - http:\/\/localhost:6001\/receive\n\n\/\/ delete message from sqs queue\n\/\/ http delete endpoint - http:\/\/localhost:6001\/delete\n<\/pre>\n<p>That is all for this tutorial and I hope the article served you with whatever you were looking for. Happy Learning and do not forget to share!<\/p>\n<h2>5. Summary<\/h2>\n<p>Localstack is the most popular aws cloud emulator which is used by individuals to run the aws applications on local machines and without connecting to the remote cloud provider. In this tutorial, we learned how to set up the localstack and integrate it with a simple nodejs application. You can download the source code and the postman collection from the <a href=\"#projectDownload\">Downloads<\/a> section.<\/p>\n<h2><a name=\"projectDownload\"><\/a>6. Download the Project<\/h2>\n<p>This was a tutorial to understand the aws cloud emulator popularly known as the localstack and its simple working in a nodejs application.<\/p>\n<div class=\"download\"><strong>Download<\/strong><br \/>You can download the full source code of this example here: <a href=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2021\/12\/LocalStack-SQS-Node.js-Example.zip\"><strong>LocalStack SQS Node.js Example<\/strong><\/a><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Hello. In this tutorial, we will interact with Amazon AWS SQS (simple queue service) to create a Node.js app with the help of a popular emulator known as LocalStack. 1. Introduction Localstack is an aws cloud service emulator that runs in a single container and allows us to run the aws applications on our local &hellip;<\/p>\n","protected":false},"author":26931,"featured_media":20900,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1879],"tags":[741,2065],"class_list":["post-112298","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-javascript","tag-node-js","tag-nodejs"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>LocalStack SQS Node.js Example - Java Code Geeks<\/title>\n<meta name=\"description\" content=\"We will interact with Amazon AWS SQS (simple queue service) to create a Node.js app with the help of a popular emulator known as LocalStack.\" \/>\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\/localstack-sqs-node-js-example.html\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"LocalStack SQS Node.js Example - Java Code Geeks\" \/>\n<meta property=\"og:description\" content=\"We will interact with Amazon AWS SQS (simple queue service) to create a Node.js app with the help of a popular emulator known as LocalStack.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.javacodegeeks.com\/localstack-sqs-node-js-example.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=\"2021-12-28T05:00:00+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2014\/01\/javascript-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=\"Yatin Batra\" \/>\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=\"Yatin Batra\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"9 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/localstack-sqs-node-js-example.html#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/localstack-sqs-node-js-example.html\"},\"author\":{\"name\":\"Yatin Batra\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/cda31a4c1965373fed40c8907dc09b8d\"},\"headline\":\"LocalStack SQS Node.js Example\",\"datePublished\":\"2021-12-28T05:00:00+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/localstack-sqs-node-js-example.html\"},\"wordCount\":916,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/localstack-sqs-node-js-example.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2014\\\/01\\\/javascript-logo.jpg\",\"keywords\":[\"Node.js\",\"nodejs\"],\"articleSection\":[\"JavaScript\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/localstack-sqs-node-js-example.html#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/localstack-sqs-node-js-example.html\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/localstack-sqs-node-js-example.html\",\"name\":\"LocalStack SQS Node.js Example - Java Code Geeks\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/localstack-sqs-node-js-example.html#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/localstack-sqs-node-js-example.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2014\\\/01\\\/javascript-logo.jpg\",\"datePublished\":\"2021-12-28T05:00:00+00:00\",\"description\":\"We will interact with Amazon AWS SQS (simple queue service) to create a Node.js app with the help of a popular emulator known as LocalStack.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/localstack-sqs-node-js-example.html#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/localstack-sqs-node-js-example.html\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/localstack-sqs-node-js-example.html#primaryimage\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2014\\\/01\\\/javascript-logo.jpg\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2014\\\/01\\\/javascript-logo.jpg\",\"width\":150,\"height\":150},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/localstack-sqs-node-js-example.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Web Development\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/category\\\/web-development\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"JavaScript\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/category\\\/web-development\\\/javascript\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"LocalStack SQS Node.js Example\"}]},{\"@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\\\/cda31a4c1965373fed40c8907dc09b8d\",\"name\":\"Yatin Batra\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/12\\\/Yatin.batra_.jpg\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/12\\\/Yatin.batra_.jpg\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/12\\\/Yatin.batra_.jpg\",\"caption\":\"Yatin Batra\"},\"description\":\"An experience full-stack engineer well versed with Core Java, Spring\\\/Springboot, MVC, Security, AOP, Frontend (Angular &amp; React), and cloud technologies (such as AWS, GCP, Jenkins, Docker, K8).\",\"sameAs\":[\"https:\\\/\\\/www.javacodegeeks.com\"],\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/author\\\/yatin-batra\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"LocalStack SQS Node.js Example - Java Code Geeks","description":"We will interact with Amazon AWS SQS (simple queue service) to create a Node.js app with the help of a popular emulator known as LocalStack.","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\/localstack-sqs-node-js-example.html","og_locale":"en_US","og_type":"article","og_title":"LocalStack SQS Node.js Example - Java Code Geeks","og_description":"We will interact with Amazon AWS SQS (simple queue service) to create a Node.js app with the help of a popular emulator known as LocalStack.","og_url":"https:\/\/www.javacodegeeks.com\/localstack-sqs-node-js-example.html","og_site_name":"Java Code Geeks","article_publisher":"https:\/\/www.facebook.com\/javacodegeeks","article_published_time":"2021-12-28T05:00:00+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2014\/01\/javascript-logo.jpg","type":"image\/jpeg"}],"author":"Yatin Batra","twitter_card":"summary_large_image","twitter_creator":"@javacodegeeks","twitter_site":"@javacodegeeks","twitter_misc":{"Written by":"Yatin Batra","Est. reading time":"9 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.javacodegeeks.com\/localstack-sqs-node-js-example.html#article","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/localstack-sqs-node-js-example.html"},"author":{"name":"Yatin Batra","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/cda31a4c1965373fed40c8907dc09b8d"},"headline":"LocalStack SQS Node.js Example","datePublished":"2021-12-28T05:00:00+00:00","mainEntityOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/localstack-sqs-node-js-example.html"},"wordCount":916,"commentCount":0,"publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/localstack-sqs-node-js-example.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2014\/01\/javascript-logo.jpg","keywords":["Node.js","nodejs"],"articleSection":["JavaScript"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.javacodegeeks.com\/localstack-sqs-node-js-example.html#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.javacodegeeks.com\/localstack-sqs-node-js-example.html","url":"https:\/\/www.javacodegeeks.com\/localstack-sqs-node-js-example.html","name":"LocalStack SQS Node.js Example - Java Code Geeks","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/localstack-sqs-node-js-example.html#primaryimage"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/localstack-sqs-node-js-example.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2014\/01\/javascript-logo.jpg","datePublished":"2021-12-28T05:00:00+00:00","description":"We will interact with Amazon AWS SQS (simple queue service) to create a Node.js app with the help of a popular emulator known as LocalStack.","breadcrumb":{"@id":"https:\/\/www.javacodegeeks.com\/localstack-sqs-node-js-example.html#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.javacodegeeks.com\/localstack-sqs-node-js-example.html"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/localstack-sqs-node-js-example.html#primaryimage","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2014\/01\/javascript-logo.jpg","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2014\/01\/javascript-logo.jpg","width":150,"height":150},{"@type":"BreadcrumbList","@id":"https:\/\/www.javacodegeeks.com\/localstack-sqs-node-js-example.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.javacodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"Web Development","item":"https:\/\/www.javacodegeeks.com\/category\/web-development"},{"@type":"ListItem","position":3,"name":"JavaScript","item":"https:\/\/www.javacodegeeks.com\/category\/web-development\/javascript"},{"@type":"ListItem","position":4,"name":"LocalStack SQS Node.js Example"}]},{"@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\/cda31a4c1965373fed40c8907dc09b8d","name":"Yatin Batra","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/12\/Yatin.batra_.jpg","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/12\/Yatin.batra_.jpg","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/12\/Yatin.batra_.jpg","caption":"Yatin Batra"},"description":"An experience full-stack engineer well versed with Core Java, Spring\/Springboot, MVC, Security, AOP, Frontend (Angular &amp; React), and cloud technologies (such as AWS, GCP, Jenkins, Docker, K8).","sameAs":["https:\/\/www.javacodegeeks.com"],"url":"https:\/\/www.javacodegeeks.com\/author\/yatin-batra"}]}},"_links":{"self":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/112298","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\/26931"}],"replies":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/comments?post=112298"}],"version-history":[{"count":0,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/112298\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media\/20900"}],"wp:attachment":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media?parent=112298"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/categories?post=112298"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/tags?post=112298"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}