Coder Social home page Coder Social logo

spring-boot-aws-mock's Introduction

spring-boot-aws-mock

Build Status Coverage Status Release

Spring Boot Starter support for Amazon Web Service Mocking.

Requirements

Windows OS is not supported

Mock Modules

  • SQS
    • Amazon Simple Queue Service

Install

Mock SQS

build.gradle

repositories {
    maven { url 'https://jitpack.io' }
}

dependencies {
    compile 'com.github.jojoldu.spring-boot-aws-mock:mock-sqs-spring-boot-starter:0.3.3'
}

Usage

Default

application.yml

cloud:
  aws:
    region:
      static: ap-northeast-2 //aws region code (required)

sqs:
  mock:
    enabled: true
  queues:
    -
      name: 'key1' 

Controller.java

public class SampleController {
    @Autowired private QueueMessagingTemplate messagingTemplate;

    @PostMapping("/url")
    public String save(@RequestBody RequestDto requestDto){
        String queueName = "key1";
        messagingTemplate.convertAndSend(queueName, requestDto);
        ...
    }

    @SqsListener(value = "key1")
    public void receive(String message, @Header("SenderId") String senderId) throws IOException {
        ...
    }
}

Run Test & Show Log

log

Integration Test

During integration testing, you must specify any port to prevent mock sqs server port conflicts.

src/test/resources/application.yml or application.properteis

sqs:
  mock:
    randomPortEnabled: true

This will run the server with the new port each time the Spring context is executed.

Options

sqs:
  mock:
    enabled: true  //required
    randomPortEnabled: true
    host: localhost
    port: 9324
  queues:
    -
      name: 'key1-dlq'
    -
      name: 'key1'
      defaultVisibilityTimeout: 1
      delay: 0
      receiveMessageWait: 0
      deadLettersQueue:
        name: "point-dlq"
        maxReceiveCount: 1
  • sqs.mock.enabled

    • false (default, not use local mock sqs)
    • true (use local mock sqs)
  • sqs.mock.randomPortEnabled

    • false (default, not use local mock sqs)
    • true (use random port)
  • sqs.mock.host

    • sqs server host
    • default: localhost
  • sqs.mock.port

    • sqs server port
    • default: 9324
AWS SQS MOCK SQS Default Value
VisibilityTimeout defaultVisibilityTimeout 30 (s)
DelaySeconds delay 0 (s)
ReceiveMessageWaitTimeSeconds receiveMessageWait 0 (s)
RedrivePolicy deadLettersQueue null
RedrivePolicy.name deadLettersQueue.name null
RedrivePolicy.maxReceiveCount deadLettersQueue.maxReceiveCount null

Example

spring-boot-aws-mock's People

Contributors

jojoldu avatar

Watchers

James Cloos 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.