jose-ramirez / spring-boot-localstack

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

spring-boot-localstack

A sample app to show how to use localstack for local developing. It receives messages coming from an incoming queue, updates their internal state, and forwards them to an outgoing queue.

You should have Docker, Docker Compose and awscli installed and working for the app to work properly.

How to test:

  • Start localstack locally: docker-compose up. This will start localstack at http://localhost:4576 with the fake credentials provided in the config files.
  • Run mvn test -Dspring.profiles.actve=test.

How to run:

  • Start localstack locally: docker-compose up. This will start localstack at http://localhost:4576 with the fake credentials provided in the config files.
  • Start the app: mvn spring-boot:run. This will create 2 queues: incoming-queue and outgoing-queue.
  • Send a message to incoming-queue:
aws --endpoint-url=http://localhost:4576 sqs send-message --queue-url http://localhost:4576/queue/incoming-queue --message-body "{\"data\": {\"nane\": \"foo\"}}"
  • The app should be generating some logs like the following:
  2022-12-19 18:45:42.231  INFO 68793 --- [enerContainer-2] c.s.localstacksqs.localsqs.Controller    : Received message on incoming queue: SampleEvent(eventId=null, version=null, type=null, eventTime=null, data=EventData(name=foo, age=0, description=null, eventType=null))
  2022-12-19 18:45:42.279  INFO 68793 --- [enerContainer-2] c.s.localstacksqs.localsqs.Controller    : Forwarded message SampleEvent(eventId=null, version=null, type=null, eventTime=2022-12-19T18:45:42.256117-03:00[America/Sao_Paulo], data=EventData(name=foo, age=0, description=null, eventType=PROCESSED)) to outgoing queue

References:

About


Languages

Language:Java 100.0%