Video: https://www.youtube.com/watch?v=0j7Veab853c
Repositories:
- https://github.com/pdincau/book-evaluation
- https://github.com/pdincau/book-service
- https://github.com/pdincau/config-server
- https://github.com/pdincau/api-gateway
- https://github.com/pdincau/eureka-server
Starts from the book-evaluation service:
git clone https://github.com/pdincau/book-evaluation
cd book-evaluation
git checkout 8d47058
mvn spring-boot:run
Test the book-evaluation service:
curl http://localhost:9991/evaluations/12345
curl http://localhost:9991/evaluations/10000
Fire off the book-service service:
git clone https://github.com/pdincau/book-service
cd book-service
git checkout f4045bf
mvn spring-boot:run
Test the book-service service:
get the actual service port looking in the log and replace it in the BOOK_SERVICE_PORT
placeholder
curl http://localhost:<BOOK_SERVICE_PORT>/books
As you can see, book-service
will ask book-evaluation
to get all the available evaluations for its books.
Run the Eureka service registry:
git clone https://github.com/pdincau/eureka-server
cd eureka-server
mvn spring-boot:run
On book-evaluation folder
git checkout master
On book-service folder
git checkout 8f22aff
On book-service folder
git checkout ca5dbd8
mvn spring-boot:run
Go to http://localhost:<BOOK_SERVICE_PORT>/hystrix to access to the Hystrix dashboard.
Monitor the following stream: http://localhost:<BOOK_SERVICE_PORT>/actuator/hystrix.stream to see how Hystrix handle successful and failing requests to downstream services.
See also https://www.logicbig.com/tutorials/spring-framework/spring-cloud/spring-circuit-breaker-hystrix-basics.html for more examples on how Hystrix works.
Feign is an alternative to Hystrix.
On book-service folder:
git checkout feign-client
mvn spring-boot:run
git clone https://github.com/pdincau/api-gateway
cd api-gateway
mvn spring-boot:run
Keep the other components unchanged:
book-service ca5dbd8
book-evaluation master
eureka-server master
Head to curl -s http://localhost:8080/api/books/
git clone https://github.com/pdincau/config-server
cd config-server
mvn spring-boot:run
On book-service folder
git checkout master
mvn spring-boot:run
see also https://gist.github.com/pdincau/c51d9c991a5b33723cfcf19f0f77b5bb