Spring Boot Intermediate Microservices: Resilient Microservices with Spring Boot 2 and Spring Cloud
By Jens Boje
()
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.
Jens Boje
Father, Software Developer, Entrepreneur
Read more from Jens Boje
Find Your Why: How I Found My Inner Drive and How You Can Too Rating: 0 out of 5 stars0 ratings
Related to Spring Boot Intermediate Microservices
Titles in the series (3)
Spring Boot 2: How To Get Started and Build a Microservice - Third Edition Rating: 5 out of 5 stars5/5Spring Boot and Single-Page Applications: Securing Your API with a Single-Page Application Frontend - Second Edition Rating: 0 out of 5 stars0 ratingsSpring Boot Intermediate Microservices: Resilient Microservices with Spring Boot 2 and Spring Cloud Rating: 0 out of 5 stars0 ratings
Related ebooks
Spring Boot and Single-Page Applications: Securing Your API with a Single-Page Application Frontend - Second Edition Rating: 0 out of 5 stars0 ratingsSpring Boot 2: How To Get Started and Build a Microservice - Third Edition Rating: 5 out of 5 stars5/5Spring and Spring Boot Interview Questions and Answers. Tech interviewer’s notes Rating: 5 out of 5 stars5/5Spring Essentials Rating: 0 out of 5 stars0 ratingsSpring MVC: Designing Real-World Web Applications Rating: 0 out of 5 stars0 ratingsMastering Spring 5.0 Rating: 5 out of 5 stars5/5Angular Essentials Rating: 0 out of 5 stars0 ratingsGetting Started with Angular - Second Edition Rating: 0 out of 5 stars0 ratingsStep by Step: Fault-tolerant, Scalable, Secure AWS Web Stack Rating: 0 out of 5 stars0 ratingsSpring MVC Cookbook Rating: 0 out of 5 stars0 ratings50 Recipes for Programming Node.js Rating: 3 out of 5 stars3/5Learn Microservices - ASP.NET Core and Docker Rating: 0 out of 5 stars0 ratingsBuilding a RESTful Web Service with Spring Rating: 5 out of 5 stars5/5Spring Boot Cookbook Rating: 0 out of 5 stars0 ratingsHacking with Spring Boot 2.4: Classic Edition: Hacking with Spring Boot, #2 Rating: 0 out of 5 stars0 ratingsRESTful Java Web Services Interview Questions You'll Most Likely Be Asked: Second Edition Rating: 0 out of 5 stars0 ratingsMastering Java EE Development with WildFly Rating: 0 out of 5 stars0 ratingsMockito Essentials Rating: 3 out of 5 stars3/5Mastering Unit Testing Using Mockito and JUnit Rating: 0 out of 5 stars0 ratingsSpring Microservices Rating: 0 out of 5 stars0 ratingsHibernate, Spring & Struts Interview Questions You'll Most Likely Be Asked Rating: 0 out of 5 stars0 ratingsTesting with JUnit Rating: 0 out of 5 stars0 ratingsGradle Essentials Rating: 0 out of 5 stars0 ratingsSpring Security 3.x Cookbook Rating: 0 out of 5 stars0 ratingsMicroservices Architecture Handbook: Non-Programmer's Guide for Building Microservices Rating: 5 out of 5 stars5/5RESTful API Design - Best Practices in API Design with REST: API-University Series, #3 Rating: 5 out of 5 stars5/5
Programming For You
HTML & CSS: Learn the Fundaments in 7 Days Rating: 4 out of 5 stars4/5Grokking Algorithms: An illustrated guide for programmers and other curious people Rating: 4 out of 5 stars4/5Python Projects for Beginners: A Ten-Week Bootcamp Approach to Python Programming Rating: 0 out of 5 stars0 ratingsLearn to Code. Get a Job. The Ultimate Guide to Learning and Getting Hired as a Developer. Rating: 5 out of 5 stars5/5SQL QuickStart Guide: The Simplified Beginner's Guide to Managing, Analyzing, and Manipulating Data With SQL Rating: 4 out of 5 stars4/5Python Programming : How to Code Python Fast In Just 24 Hours With 7 Simple Steps Rating: 4 out of 5 stars4/5Coding All-in-One For Dummies Rating: 4 out of 5 stars4/5Learn PowerShell in a Month of Lunches, Fourth Edition: Covers Windows, Linux, and macOS Rating: 0 out of 5 stars0 ratingsJava for Beginners: A Crash Course to Learn Java Programming in 1 Week Rating: 5 out of 5 stars5/5The Unofficial Guide to Open Broadcaster Software: OBS: The World's Most Popular Free Live-Streaming Application Rating: 0 out of 5 stars0 ratingsPYTHON: Practical Python Programming For Beginners & Experts With Hands-on Project Rating: 5 out of 5 stars5/5Hacking: Ultimate Beginner's Guide for Computer Hacking in 2018 and Beyond: Hacking in 2018, #1 Rating: 4 out of 5 stars4/5SQL All-in-One For Dummies Rating: 3 out of 5 stars3/5The Little SAS Book: A Primer, Sixth Edition Rating: 5 out of 5 stars5/5Excel : The Ultimate Comprehensive Step-By-Step Guide to the Basics of Excel Programming: 1 Rating: 5 out of 5 stars5/5SQL: For Beginners: Your Guide To Easily Learn SQL Programming in 7 Days Rating: 5 out of 5 stars5/5Python: For Beginners A Crash Course Guide To Learn Python in 1 Week Rating: 4 out of 5 stars4/5Teach Yourself C++ Rating: 4 out of 5 stars4/5Pokemon Go: Guide + 20 Tips and Tricks You Must Read Hints, Tricks, Tips, Secrets, Android, iOS Rating: 5 out of 5 stars5/5
Reviews for Spring Boot Intermediate Microservices
0 ratings0 reviews
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
>