Git Product home page Git Product logo

springboot-sqs-example's Introduction

spring-boot-sqs-example

Example application to show how to send and consume messages to and from an AWS SQS queue with Spring Boot

What you will need to run the application

  1. An AWS Account
  2. AWS Access Keys
  3. Create an SQS queue

How to run it?

Package the application as a Docker image and run as a Docker container

To build the Docker image use the following command:

docker build -t spring-boot-sqs-example .

To run the Docker container use the following command and make sure to replace ACCESS_KEY_ID_HERE and SECRET_ACCESS_KEY_HERE with your AWS credentials:

docker run --env AWS_ACCESS_KEY_ID=ACCESS_KEY_ID_HERE --env SQS_NAME=XXXXXXXXXXX --env AWS_SECRET_ACCESS_KEY=SECRET_ACCESS_KEY_HERE --env AWS_REGION=REGION -p 8080:8080 spring-boot-sqs-example 

How do I test the application?

Using curl make the following post request to place an order which will send the message to queue

curl -i -X POST -H "Content-Type: application/json" -d "{\"reference\" : \"T000000012345\",\"userId\" :\"TEST_USERID\",\"coupon\": \"FIRSTBUY15OFF\",\"products\" : [{ \"productId\": \"PRODUCT1\",\"productName\": \"Baggy Jeans\",\"price\": 26.78,\"code\": \"T0012\"}]}"  http://localhost:8080/api/v1/orders

Use the following command to see application logs:

docker logs CONTAINER_ID --follow

In your application logs you should see the order being received and send to the queue, then see the service listening on the queue pick the message and process the order

springboot-sqs-example's People

Contributors

naresh240 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.