Skip to content

spring-cloud-services-samples/fortune-teller

CircleCI

Fortune Teller

Fortune Teller is a very basic application composed of two services:

  1. Fortune Service - serves up random Chinese fortune cookie fortunes

  2. 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.

Fortune Teller is deployable to any Cloud Foundry environment utilizing the service components that have been packaged with the project. However, it is most easily deployed to Pivotal Cloud Foundry environments that have installed the Spring Cloud Services package.

Build

  1. 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.

Deploy to Pivotal Cloud Foundry with Spring Cloud Services

  1. Run scripts/pcf-create-services.sh to create the services that you need:

    $ ./scripts/pcf-create-services.sh
    Creating service fortunes-db in org microservices / space fortune-teller as admin...
    OK
    Creating service config-server in org microservices / space fortune-teller as admin...
    OK
    Creating service service-registry in org microservices / space fortune-teller as admin...
    OK
  2. Click on the Manage links for the Config Service and Service Registry. Make sure the services are finished initializing before you proceed.

  3. Edit the manifest-pcf.yml file to specify the Cloud Foundry target the apps are being pushed to, replacing the URL in CF_TARGET: https://api.yourpcfenvironment.local with the API endpoint for your Cloud Foundry deployment.

  4. Push the microservices:

    $ cf push -f manifest-pcf.yml

    This will push the fortunes service and the ui application and bind all of the services.

Test the Application

  1. In a browser, access the fortunes-ui application at the route that was created for you:

    fortunes 1

  2. Stop the fortunes application:

    $ cf stop fortune-service
  3. Access the fortunes-ui and see that the default fortune is being returned.

    fortunes 4

  4. Start the fortunes application:

    $ cf start fortune-service
  5. Continue to access the fortunes-ui. After the fortunes service has re-registered with Eureka and the fortunes-ui load balancer caches are refreshed, you should then start getting random fortunes again!

About

A sample application that demonstrates the usage of Spring Cloud Services on Pivotal Cloud Foundry

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published