This mono repo contains two microservices projects wich I used to implement Asynchronous communication between them, using RabbitMQ.
- Docker and Docker Compose installed on your machine.
-
Clone the Repository
git clone https://github.com/charlybutar21/microservice-rabbitmq
-
Start RabbitMQ with Docker
cd microservice-rabbitmq docker-compose up
-
Setup RabbitMQ
After RabbitMQ is up and running, you need to create the necessary components:
- Create Exchange: user.exchange
- Create Queue: user.queue
- Create Binding: Bind user.queue to user.exchange
-
Run Microservices
Run producer-service and consumer-service.
-
Send a Request
POST http://localhost:8081/api/produce Content-Type: application/json { "userId": "ID2", "userName": "rodriguez" }
-
Verify the Data
Open http://localhost:8080/h2-console,
url: jdbc:h2:mem:testdb,
username: sa
password: