Fortune Teller is a very basic application composed of two services:
-
Fortune Service - serves up random Chinese fortune cookie fortunes
-
Fortune UI - presents a UI that consumes the fortune service
It leverages libraries and services from Spring Cloud and Netflix OSS to compose the system.
Note
|
Want to deploy Fortune Teller to Pivotal Cloud Foundry environments that have installed the Spring Cloud Services package? See the SCS version of Fortune Teller. |
-
Using Maven, build and package the application:
$ mvn clean package
Maven will automatically download all of Fortune Teller's dependencies. This may take a few moments.
-
Start the Config Server
$ cd fortune-teller-config-server $ mvn spring-boot:run
-
Start the Eureka Service
$ cd fortune-teller-eureka $ mvn spring-boot:run
-
Start the Hystrix Dashboard
$ cd fortune-teller-hystrix-dashboard $ mvn spring-boot:run
-
Start the Fortunes Service
$ cd fortune-teller-fortune-service $ mvn spring-boot:run
-
Start the Fortunes UI
$ cd fortune-teller-ui $ mvn spring-boot:run
-
In a browser, access the fortunes-ui application at http://localhost:8081/
-
Now, in another browser tab, access the Hystrix Dashboard at http://localhost:7979/hystrix/. Enter the route for the UI application,
http://localhost:8081/hystrix.stream
, and click the ``Monitor Stream.'' -
Access the fortunes-ui and show that the circuit breaker is registering successful requests.
-
Stop the fortunes application
-
Access the fortunes-ui and see that the ``fallback fortune'' is being returned.
-
Access the fortunes-ui and show that the circuit breaker is registering short-circuited requests.
-
Restart the fortunes application
-
Continue to access the fortunes-ui and watch the dashboard. After the fortunes service has re-registered with Eureka and the fortunes-ui load balancer caches are refreshed, you will see the circuit breaker recover. You should then start getting random fortunes again!