## This project is a revision of the original demo project by piotr_minkowski. New features added include:
- Keycloak as the OAuth2 server and OIDC provider to enable security
- Spring Cloud Gateway as OAuth2 resource server
In this project I'm demonstrating you how to use Hashicorp's Consul as a discovery and configuration server with Spring Cloud Consul and other Spring Cloud projects for building microservice-based architecture.
- To build and run sample applications you need to have Maven, JDK11+ and Docker. However, the simplest way to start with it is through any IDE like Intellij or Eclipse.
- First, you have to run Consul on Docker container
$ docker run -d --name consul-1 -p 8500:8500 -e CONSUL_BIND_INTERFACE=eth0 consul
- Then you can compile your application with Maven
mvn clean install
command and usingjava -jar ...
command. Or you can just build it and run using your IDE. Each application is listeting on dynamically generated port.
Our sample microservices-based system consists of the following modules:
- gateway-service - a module that uses Spring Cloud Gateway for running Spring Boot application that acts as a proxy/gateway in our architecture.
- account-service - a module containing the first of our sample microservices that allows to perform CRUD operation on in-memory repository of accounts
- customer-service - a module containing the second of our sample microservices that allows to perform CRUD operation on in-memory repository of customers. It communicates with account-service.
- product-service - a module containing the third of our sample microservices that allows to perform CRUD operation on in-memory repository of products.
- order-service - a module containing the fourth of our sample microservices that allows to perform CRUD operation on in-memory repository of orders. It communicates with all other microservices.
The following picture illustrates the architecture described above.
When running sample applications we can test more advanced scenario. We may leverage Zone Affinity mechanism to prefer communication inside a single zone. We can also start a cluster of Consul modes started locally on Docker containers. Here's the picture illustrating such an architecture:
Detailed description can be found here: Microservices with Spring Boot, Spring Cloud Gateway and Consul Cluster