Discover millions of ebooks, audiobooks, and so much more with a free trial

Only $11.99/month after trial. Cancel anytime.

Spring Boot Intermediate Microservices: Resilient Microservices with Spring Boot 2 and Spring Cloud
Spring Boot Intermediate Microservices: Resilient Microservices with Spring Boot 2 and Spring Cloud
Spring Boot Intermediate Microservices: Resilient Microservices with Spring Boot 2 and Spring Cloud
Ebook101 pages55 minutes

Spring Boot Intermediate Microservices: Resilient Microservices with Spring Boot 2 and Spring Cloud

Rating: 0 out of 5 stars

()

Read preview

About this ebook

Learn how to access a microservice and build a reliable infrastructure using Spring Boot 2 and Spring Cloud with a proven actionable and hands-on approach
Learning new technology can be fast and fun. With this custom tailored learning plan you advance in building microservices with Spring Boot by actually building applications.

Together we build a tiny application using the microservice we created in "Spring Boot: How To Get Started and Build a Microservice" and expand the scenario with common patterns used in microservice environments for building a reliable fault tolerant infrastructure. You can follow along without having read the previous book.

You learn best by coding.

We use Spring Boot 2 with the Milestone 2.

What you will build:
We will write a simple client application for our microservice and improve it with each step to handling load balancing, failovers, service discovery and more.

What you will learn:
How to access a remote API with Spring's RestTemplate
How to do retries and fallbacks in case of API errors
How to add client side load balancing to it
How to use the circuit breaker pattern with Spring Cloud
How to register and discover services
What the role of a gateway is

How you can easily add a gateway
How to store configurations in a central place

This book is for you when
you have started using Spring Boot
you want to improve on microservices and Spring Boot
you love building applications and learning new technologies

It is NOT for you if
your most advanced program was HelloWorld
you like reading fluffy compendiums
you don't know the Java language at all

Also, if you have questions, do not hesitate and contact me using the email address at the end of the book. I'll answer your questions and improve the book with your feedback.

LanguageEnglish
PublisherJens Boje
Release dateJul 22, 2017
ISBN9781370314089
Spring Boot Intermediate Microservices: Resilient Microservices with Spring Boot 2 and Spring Cloud
Author

Jens Boje

Father, Software Developer, Entrepreneur

Read more from Jens Boje

Related to Spring Boot Intermediate Microservices

Titles in the series (3)

View More

Related ebooks

Programming For You

View More

Related articles

Reviews for Spring Boot Intermediate Microservices

Rating: 0 out of 5 stars
0 ratings

0 ratings0 reviews

What did you think?

Tap to rate

Review must be at least 10 words

    Book preview

    Spring Boot Intermediate Microservices - Jens Boje

    Introduction

    This book’s approach differs from that of other programming books that you may have encountered. That’s because I believe that the best way to learn a new framework or language is to build applications using it.

    We will build upon our sample microservice we created in the book Spring Boot - How to get Started and Build a Microservice, add a consuming application and then build a fault tolerant environment using common microservice patterns.

    What we will build in this book

    We start with a simple consuming application using Springs RestTemplate to access the microservice

    We enhance this by adding Spring Retry for making it a bit more reliable

    We add client-side load balancing to make it even more reliable

    We then replace our retry mechanism with the circuit breaker pattern to level up

    We introduce service discovery patterns to make it easier to add new instances of a microservice

    We introduce a gateway to make the UI of the consumer and the API of the commentstore microservice available behind one entry point

    As the services and thus complexity grow we will externalize the configuration

    The full source code for this book’s sample applications is available on GitHub: Link

    Each step resides in its own branch.

    I’ll explain the most relevant code in the book with code samples. However, I do skip the code for certain simple helper classes, but you can always find them in the source code.

    What You Will Need

    Java 8

    Maven (3.2+)

    Text editor or IDE of your choice. I use Spring Tools Suite but it is not required to follow along.

    Installing and setting them up is not in the scope of this book.

    Building the Consumer Application

    The consumer application is a simple Spring Boot application with one page displaying a mock product, showing the comments for it, and a form to submit a new comment. The product and product retrieval are mocked; the comments are actually handled. In a real application, the products would be in its own microservice and the same principals apply as we are using with the commentstore microservice.

    You can find the source code in the GitHub repository in the branch consumer-simple.

    I recommend that you clone the repository and begin with the master branch, and gradually follow along. The master branch already contains an updated version of the commentstore microservice using Spring Boot 2. I also deployed it to Heroku and for the first few steps, you can use my Heroku instance as the backend. However, starting with the service registry you will need to run all locally.

    The commentstore is deployed at https://boiling-retreat-23464.herokuapp.com

    Let’s start with implementing the consumer application.

    Create a new Spring Boot application using the web, thymeleaf, devtools and test starters. Your pom should look like:

     

     

    xmlns=http://maven.apache.org/POM/4.0.0

     

     

    xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance

     

     

    xsi:schemaLocation=http://maven.apache.org/POM/4.0.0     http://maven.apache.org/xsd/maven-4.0.0.xsd>

     

     

    4.0.0

     

     

     

       

    org.springframework.boot

     

       

    spring-boot-starter-parent

     

       

    2.0.0.M2

     

     

     

     

    de.codeboje.springbootbook

     

     

    1.0.0-SNAPSHOT

     

     

    consumer

     

     

    Spring Boot Intermediate Microservice Book - Consumer App

     

     

     

     

       

     

         

    org.springframework.boot

     

         

    spring-boot-starter-web

     

       

     

       

     

         

    org.springframework.boot

     

         

    spring-boot-starter-thymeleaf

     

       

     

       

     

         

    org.springframework.boot

     

         

    spring-boot-devtools

     

         

    true

     

       

     

       

     

     

    Enjoying the preview?
    Page 1 of 1