Microservices in Java based on the course of Microservices and Distributed Systems by AmigosCode with a DDD architectural approach
This project shows an example of a Client registration endpoint that communicates between different microservices. Once we call the endpoint we make a call to a Fraud microservice that queries the database and checks if a user is a fraud or not. In the case where a user is valid, it then uses a Kafka Queue to insert the notification message of the new user. The Notification microservice consumes this queue and sends an Email to the end client.
To help monitor these services, we use a few different tools. For response timings and tracing we use Zipkin which collects data from all our microservices. For logging we use the ELK stack (ElastiSearch, Logstash and Kibana).
To manage the microservices we use Netflix's Eureka Server. Alongside this we also use the Spring API Gateway as an entrypoint to our Customer endpoint.
For a security measure as well as general code maintenance it's also included in the dockerfile a sonarqube instance to run against our code.
To be able to run the docker containers locally, these environment variables need to be set.
SPRING_MAIL_HOST=
SPRING_MAIL_PORT=
SPRING_MAIL_USERNAME=
SPRING_MAIL_PASSWORD=
SONAR_USERNAME=
SONAR_PASSWORD=
ELASTICSEARCH_USERNAME=
ELASTICSEARCH_PASSWORD=
docker compose up -dmvn clean package -P build-docker-imageTo have the notifications microservice work, we need to supply the following environment variables to the project to have the smtp server work. We can either add these to the application.properties file or to the docker environment variables when we run the program. This can also be achieved locally with a .env file mentioned above.
-Dspring.mail.host=<host> -Dspring.mail.port=<port> -Dspring.mail.username=<Username> -Dspring.mail.password=<Password>To have sonarqube be able to work we must create a user on the postgres database and setup it's respective password. These can be stored on a .env file.
After this we create a database called sonar and finally run the container.
