We will use two microservices to demonstrate concepts in this chapter:
- Microservice A: A simple microservice exposing two services--one to retrieve a message from the configuration file and another
random service
providing a list of random numbers. - Service consumer microservice: A simple microservice exposing a simple calculation service called the
add
service. Theadd
service consumes therandom service
from Microservice A and adds the numbers up.
The following figure shows the relationship between the microservices and the services that are exposed:
Let's quickly set up these microservices.
Let's use Spring Initializr (https://start.spring.io) to get started with Microservice A. Choose GroupId
, ArtifactId
, and the frameworks, as shown in the following screenshot:
We will create a service to expose a set of random numbers:
@RestController public class RandomNumberController { private Log log = LogFactory.getLog(RandomNumberController...