Fortune Teller is a demo project written in Kotlin, showcasing cloud-native technologies such as Spring Boot and Spring Cloud.
Thanks to Spring Cloud Services for PCF, this app is leveraging key technologies for microservices:
- Netflix Eureka: a service registry for locating microservices;
- Netflix Ribbon: a client-side load balancer to distribute load among microservices;
- Netflix Hystrix: a latency and fault tolerance library;
- Open Feign: a REST client library that allows you to consume HTTP APIs with minimal overhead.
This app is made of two main components:
fortune-service
: a microservice connected to a database, serving fortunes;fortune-ui
: a simple HTML frontend, rendering fortunes to users.
Compile this project using Maven and JDK 8:
$ ./mvnw clean package
When running locally, this app requires an Eureka server:
$ java -jar eureka-server/target/eureka-server.jar
You also need to run a RabbitMQ server. The easiest way is to use the official RabbitMQ Docker image:
$ docker run --hostname rabbit --rm -p "5672:5672/tcp" rabbitmq:3
You are now ready to start the two main components:
$ java -jar fortune-service/target/fortune-service.jar
$ java -jar fortune-ui/target/fortune-ui.jar
You may want to start more processes. All you need is to set a different port for each process:
$ PORT=1234 java -jar fortune-service/target/fortune-service.jar
$ PORT=5678 java -jar fortune-service/target/fortune-service.jar
Thanks to Eureka, these new processes are automatically registered, and consumers like
fortune-ui
seamlessly access these services.
Prior to deploying this app to Pivotal Cloud Foundry, you need to create required services:
$ cf create-service p-circuit-breaker-dashboard standard circuit-breaker
$ cf create-service p-service-registry standard service-registry
Monitor service creation (it can take some time):
$ cf services
name service plan bound apps last operation
circuit-breaker p-circuit-breaker-dashboard standard create succeeded
service-registry p-service-registry standard create succeeded
Now it's time to deploy the app to PCF:
$ cf push
In case you want to deploy to Pivotal Web Services (a public instance of PCF for testing purposes), you should use a different manifest when pushing the app:
$ cf push -f manifest-pws.yml
Contributions are always welcome!
Feel free to open issues & send PR.
Copyright © 2018 Pivotal Software, Inc.
This project is licensed under the Apache Software License version 2.0.