Please note
-
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.
Service design
Key points:
-
A service consists of a single Gradle module. For example,
ftgo-order-serviceimplements theOrder Service -
A service is a Spring Boot application
-
A service has a Swagger UI
http://…/swagger-ui.html. Seeopen-swagger-uis.sh -
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
-
Eventuate Tram framework- implements transactional messaging -
Eventuate Tram Saga framework- implements sagas -
Eventuate Client framework- implements event sourcing
-
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
Eventuate Tramframework
Chapter 7 Implementing queries in a microservice architecture
-
ftgo-order-history-service is an example of a CQRS view
-
ftgo-api-gateway uses API composition to implement the REST endpoint for retrieving the order history
Building and running the application
Pre-requisites
-
Java 8+
-
Docker and Docker Compose
-
Internet access so that Gradle and Docker can download dependencies and container images
Building
Temporary: Build the Spring Cloud Contracts using this command:
Build the services using this command:
Deploying the application on Kubernetes
Setting environment variables to do development
You should not need to set any environment variables.
To run the application, you certainly do not.
Similarly, to do development (e.g. run tests), you typically do not need to set any environment variables.
That’s because Docker containers are generally accessible (e.g. Docker for Windows/Mac) on the host via localhost.
However, if Docker is running elsewhere (e.g. you are using Docker Toolbox) you will need to set DOCKER_HOST_IP.
Long way
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, localhost or 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.
