This project is an example of microservice architecture in Spring Boot using Maven.
Request that is going through all components in this architecture is customer creation. 🕺
- Client send a POST request to localhost:8083/api/v1/customer with a sample body:
{
"firstName": "Andrew",
"lastName": "Huang",
"email": "[email protected]"
}
-
Request is sent to Api Gateway from where it is redirected to correct microservice -> Customer.
-
Customer microservice saves customer and checks if is fraudster by sending proper request to Fraud microservice.
-
After Fraud microservice response, the notification about customer creation is sent to Kafka.
-
The Notification microservice gets the notification from Kafka and saves it to the DB
- Java 17 ❤️
- Maven
- Docker
For simplicity, we will use docker to run: postgres, pgadmin, zookeeper, kafka, zipkin.
docker-compose up postgres pgadmin zookeeper kafka zipkin -d
Before running docker, change in docker-compose.yaml file line 83 to:
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://localhost:9092,PLAINTEXT_INTERNAL://kafka:29092
Now, we can run the rest of the microservices locally:
- eureka-server
- apigw
- customer
- fraud
- notification
You can run them through the IDE or using command
mvn spring-boot:run
inside every microservice folder.
To run everything in docker just type:
docker-compose up -d
To deploy changes made in microservices, go to the root folder of the project and run:
mvn clean package -P build-docker-image
docker login
.