chapter three

Chapter 3: Building microservices with Spring Boot

 

This chapter covers

  • Understanding how microservices fit into a cloud architecture
  • Decomposing a business domain into a set of microservices
  • Understanding the perspectives for building microservice-based applications
  • Learning when not to use microservices
  • Implement a microservice using Spring Boot, Spring Actuator, Spring Hypermedia as the Engine of Application State (HATEOAS), and Internationalization.

To successfully design and build microservices, you need to approach microservices as if you’re a police detective interviewing witnesses to a crime. Even though every witness saw the same events take place, their interpretation of the crime is shaped by their background, what was important to them (for example, what motivates them), and what environmental pressures were brought to bear at the moment they witnessed the event. Participants each have their own perspectives (and biases) of what they consider essential.

Like successful police detecting trying to get the truth, the journey to build a successful microservice architecture involves incorporating the perspectives of multiple individuals within your software development organization. Although it takes more than technical people to deliver an entire application, I believe that the foundation for successful microservice development starts with the perspectives of three critical roles:

3.1      Making sure our examples are relevant

3.2      The architect’s story: designing the microservice architecture

3.2.1   Decomposing the business problem

3.2.2   Establishing service granularity

3.2.3   Defining the service interfaces

3.3      When not to use microservices

3.3.1   Complexity of building distributed systems

3.3.2   Server sprawl

3.3.3   Type of application

3.3.4   Data transactions and consistency

3.4      The developer’s tale: building a microservice with Spring Boot and Java

3.4.1   Setting up the environment

3.4.2   Getting started with the skeleton project

3.4.3   Booting your Spring Boot application: Writing the Bootstrap class

3.4.4   Building the doorway into the microservice: The Spring Boot controller

3.4.5   Applying internationalization into the licensing service

3.4.6   Implementing Spring HATEOAS to display related links

3.5      The DevOps story: building for the rigors of runtime

3.5.1   Service assembly: packaging and deploying your microservices

3.5.2   Service bootstrapping: managing configuration of your microservices

3.5.3   Service registration and discovery: how clients communicate with your microservices

3.5.4   Communicating a microservice’s health