This is an implementation of https://www.youtube.com/watch?v=ZyK5QrKCbwM using the bellow versions:
- org.springframework.boot 2.0.5.RELEASE
- org.springframework.cloud Finchley.SR1
- Java 11
Uses the spring-cloud-config-server in order to allow other modules to get the properties from a centralized site. The folder microservices-config contains the properties files for the modules eureka-service, reservation-client, reservation-service, and hystrix-dashboard. This folder could be located in the github repository or in a local system. The property spring.cloud.uri must be modified according to this set up. If the folder microservices-config is located in a local system, it must be initialized as a git hub repository anyway. (Just use git init)
Uses the spring-cloud-starter-netflix-eureka-server to enable a server for registering, discovering and load balancing microservices. (more info).
The service connects to config-server to get all properties, but it needs to set up inside the module all the properties to connect to config-server. (in the application.properties file)
Spring boot application that exposes services for saving a reservation, list reservations and get a message. The service connects to config-server to get all properties, but it needs to set up inside the module all the properties to connect to config-server. (in the application.properties file). Also, in the config-server is defined the properties to connect to Kafka and exposes the actuator endpoints.
The reservation-service is listening to receive any data coming from Kafka service and save a reservation.
It uses spring-cloud-starter-netflix-zuul to create a proxy server. The service connects to config-server to get all properties, but it needs to set up inside the module all the properties to connect to config-server. (in the application.properties file). Also, in the config-server is defined the properties to connect to Kafka, exposes the actuator endpoints, and define the routes for Zuul service.
The reservation-client exposes the POST service reservations, which recive the data and send it to a Kafka service.
Here more info about how to implement a kafka client (producers and consumers).
Here more infor about how to implement Netflix-Zuul.
To support the tolerance, and monitor the services status. (more info and here).
The reservations-service and reservation-client active the hystrix by using the tags @EnableCircuitBreaker and @HystrixCommand.
The service connects to config-server to get all properties, but it needs to set up inside the module all the properties to connect to config-server. (in the application.properties file)
It's a docker image. The docker compose file is located at kafka folder (more info)
It's docker image to monitor services (more info)
- Set up java 11
- Set up/Install docker (more info)
- Install docker-compose (not needed on Windows)
- In the config-server module, it's needed to update the property spring.cloud.config.server.git.uri in the application.properties according with the locally in the current enviorment. The folder microservices-config must be a git repository if you want to use a local folder.
- Start the kafka docker image. Go to kafka folder and execute the below command: docker-compose up -d
- Start the Zipkin docker image by executing the below command: docker run -d -p 9411:9411 openzipkin/zipkin
- Build the jar files by executing the following command on the root path of the building-microservices mvn clean install
- Start each services by executing the following command (located at the roort path of the building-microservices): java -jar config-server\target\config-server-0.0.1-SNAPSHOT.jar java -jar eureka-service\target\eureka-service-0.0.1-SNAPSHOT.jar java -jar hystrix-dashboard\target\hystrix-dashboard-0.0.1-SNAPSHOT.jar java -jar reservation-client\target\reservation-client-0.0.1-SNAPSHOT.jar java -jar reservation-service\target\reservation-service-0.0.1-SNAPSHOT.jar
-
Testing Netflix-Zuul proxy
The following image shows the reservations list service get from the reservation-service server.
The following image shows the reservations list service get from the reservation-client server by using zuul proxy.
The following image shows how to add the hystrix stream to the hystrix dashboard. After adding the hystrix.stream url, clic on "monitor stream".
The below image shows hystrix stats when all services are working correctly.
Now, you can stop the reservation-service and see how the stats change.
-
Testing Kafka
In the left image, you can see the names services called from the browser. After, from postman we added a new reservation (middle image). Finally, in the right image you can see the new reservation was added. In fact, the reservation-client (producer) sent the reservation to the Kafka service, and the reservation-service (consumer) is listening for any change on Kafka service to read the tail and create a new reservation. -
Testing Zipkin
You need to go to the Zipkin home page and add the service to monitor You can see more details by clicking on "show" button.