FTGO example application
The code is still work in progress
It primarily illustrates the technical aspects of the microservice architecture and so the business logic is minimal
The documentation is sparse/non-existent and you will need to look in the book
The application consists of many services and so requires a lot of memory. It runs well, for example, on a 16GB Macbook pro.
The application’s services and the infrastructure services, such as MySQL and Apache Kafka, are deployed using Docker containers using either Docker Compose or Kubernetes.
Please post a message to the book’s discussion forum or create a github issue. I’ll do my best to help you.
Not surprisingly, this application has a microservice architecture. There are the following services:
ftgo-consumer-service - the
ftgo-restaurant-service - the
ftgo-order-service - the
ftgo-kitchen-service - the
ftgo-accounting-service - the
ftgo-order-history-service - a
Order History Service, which is a CQRS view
ftgo-api-gateway - the API gateway
A service consists of a single Gradle module. For example,
A service is a Spring Boot application
A service has a Swagger UI
A service typically consists of the following packages:
domain - domain logic including aggregates
messaging - messaging adapters
web - Spring MVC controllers (HTTP adapters)
main - the main application
The services use the following other frameworks
Chapter by chapter
This section maps the chapters to the code.
Chapter 3 Inter-process communication in a microservice architecture
The services have a REST API
The services also communicate using the Apache Kafka message broker via the
Chapter 4 Managing transactions with sagas
The ftgo-order-service uses sagas to maintain data consistency:
The services that participate in these sagas define the following command handlers:
Chapter 5 Designing business logic in a microservice architecture
All the services' business logic is implemented using Domain-Driven design aggregates.
Chapter 6 Developing business logic with event sourcing
Chapter 7 Implementing queries in a microservice architecture
Chapter 8 External API patterns
ftgo-api-gateway is the API gateway
Building and running the application
Docker and Docker Compose
Internet access so that Gradle and Docker can download dependencies and container images
Temporary: Build the Spring Cloud Contracts using this command:
Build the services using this command:
Setting environment variables
A quick way to set the environment variables is to run the script
To run the application you must set the
DOCKER_HOST_IP environment variable to the IP address of where the Docker containers are running:
Docker toolbox/Virtual machine - IP address of the virtual machine
Docker for Windows/Mac/Linux - IP address of your laptop/desktop
The value of
DOCKER_HOST_IP must be meaningful to both Java services/tests running on your desktop/laptop and to Docker containers.
Please do NOT set it to the unresolvable hostname of your machine,
127.0.0.1 since the Docker containers will probably not work correctly.
Verifying that DOCKER_HOST_IP is set correctly
You can verify that
DOCKER_HOST_IP is set correctly by running this command:
docker run -p 8889:8888 -e DOCKER_DIAGNOSTICS_PORT=8889 -e DOCKER_HOST_IP \ --rm eventuateio/eventuateio-docker-networking-diagnostics:0.2.0.RELEASE
Setting the environment variable in your IDE
If you want to run Java services/tests within your IDE on your desktop/laptop AND the Docker containers are not accessible via
localhost THEN you will need to set
DOCKER_HOST_IP within your IDE.
How to do this depends on your operating system and IDE.
For example, I find it convenient to launch my IDE from the command line and after setting this environment variable.
Running the application
Run the application using this command:
docker-compose up -d
This can take a while.
Using the application
Use the services Swagger UIs to invoke the services.
Create consumer -
Create a restaurant -
Create an order -
View the order -
View the order history -
You can also access the application via the
API Gateway at
However, currently it doesn’t have a Swagger UI so you will have to use
curl, for example.
Stopping the application
Stop the application using this command:
docker-compose down -v
Deploying the application on Kubernetes
You can find Kubernetes YAML files in the following directories:
There are also some helpful shell scripts.
You can run this command
Undeploying the services
You can run the script to undeploy the services:
If you want to delete the persistent volumes for Apache Kafka, Zookeeper and MySQL please run the command: