Skip to content

Instantly share code, notes, and snippets.

@xpepper
Last active December 1, 2019 11:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xpepper/c63df3182c1c0575a420cfc4c04c690a to your computer and use it in GitHub Desktop.
Save xpepper/c63df3182c1c0575a420cfc4c04c690a to your computer and use it in GitHub Desktop.
Paolo D'Incau's talk on Spring Cloud

Video: https://www.youtube.com/watch?v=0j7Veab853c

Repositories:

Roadmap

1st version: one service calling directly another downstream service

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.

2nd version: client-side service discovery and multiple instances of book-evaluation

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

3rd version: Hystrix and Feign

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.

Have a look at the Feign alternative

Feign is an alternative to Hystrix.

On book-service folder:

git checkout feign-client
mvn spring-boot:run

4th version: API Gateway

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/

5th version: Configuration Server

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
@xpepper
Copy link
Author

xpepper commented Nov 28, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment