To understand microservices concepts better, we will use an example-driven approach.
We will build two microservices that talk to each other—Microservice A and the Service Consumer. Microservice A exposes a random number service that is consumed by the Service Consumer microservice.
A few more details about each of these microservices are as follows:
- Microservice A: This is a simple microservice that exposes two services—one to retrieve a message from the configuration file and another random service that provide a list of five random numbers.
- Service Consumer microservice: This is a simple microservice that exposes a simple calculation service called the add service. The add service consumes the random service from Microservice A and adds the numbers up.
The following diagram shows the relationship between the microservices and the services that are exposed:
Let's get started by setting up these microservice examples. We will use SPRING INITIALIZR to quickly set them up.