quarta-feira, 4 de setembro de 2019

Spring Boot + Docker + Postgree + RabbitMQ



Some time ago I was looking for a solution for a Java integration. Where the requirements were: Java - Microservices + Docker + PostgreSQL + RabbitMQ. I found few articles on the internet that could help me due to various settings so I decided to create mine.

RabbitMQ configuration should configure the topic and queue name, where messages will be sent and received.


For the persistence configuration in PostgreSQL you must use a simple class with the necessaryproperties for each project. change it as necessary.


Receiver setup is very simple.

Initializing an employee.


In Runner class was instantiated the receiver and to RabbitTemplate, so that it could check the employee inserted in Postgre and send it to the topic.

 The settings for PostgreSQL and RabbitMQ in the application.properties file.

Be sure to follow these lines in the database.

Settings in Docker are important as they respect the start sequence of containers to ports. A network called webnet was also created, if you have other containers and have connection problems refused.


Dockerfile in this case uses JDK 11, but can be replaced with your preferred distribution.

Commands:

mvn clean package
docker-compose build
docker-compose up

The whole code can be found on github.




Nenhum comentário:

Postar um comentário