
Build coupon and product microservices that communicate via REST and register with Eureka. Explore Feign clients, Ribbon, Hystrix, Zuul, and Sleuth for routing, fault tolerance, and tracing.
Discover a complete hands-on Spring Cloud Fundamentals course organized by sections, with quizzes, assignments, and practical projects; install Spring Tools Suite and MySQL Workbench to start.
Install the latest JDK and Spring Tool Suite, then configure STS to use a Java SE JDK. Follow OS-specific installers and point STS to the JDK home directory.
Install and configure MySQL and MySQL Workbench using a three-step process: download the installer, install both components, and set a root password to log in and run sql statements.
Launch MySQL Workbench, create a local connection to localhost:3306 as root, test the connection by entering the password, then open a query window and run create database My DB.
Install a MySQL community server on Windows by installing Visual C++ prerequisites, running the installer, configuring port 3306 and password encryption, then use MySQL Workbench to connect.
Install and launch MySQL Workbench, a GUI client to connect to MySQL servers, create databases, use them, and run queries from a local default connection or remote cloud connections.
Install postman on Windows, Linux, or Mac, launch API development environment, and use it to test RESTful microservices with get, post, put, patch methods, headers, json bodies, and basic authentication.
Download the completed projects from the resources section, unzip the spring cloud zip to access source code, maven dependencies, and configurations, and compare your work if issues arise.
Download the assignment solutions from the resources of this lecture to reference the code and configuration, and avoid copying. Complete all assignments from scratch and submit them for review.
Discover how Spring Cloud enables microservices with service registration, discovery, load balancing, fault tolerance, security, and distributed tracing using Eureka, Hystrix, Zuul, Sleuth, and Zipkin.
Set up two microservices, coupon and product, on local ports using spring cloud components such as eureka, zuul, and config, with ports 8080, 8081, 1990, 8761, 8765, 8888, and 9411.
Create a product microservice and a coupon microservice with restful APIs; the product service applies coupon discounts by querying the coupon service and saves the discounted product to the database.
Create product and coupon tables for the product and coupon microservices using SQL in MySQL Workbench; define product(id auto increment, name, description, price) and coupon(id, coupon_code unique, discount, expiry date).
Create a coupon service Spring Boot project using Spring tools, naming it coupon service with group com.barath.springcloud.com, including Spring Web, Spring Data JPA, and MySQL driver.
Create a coupon model as a JPA entity with id, coupon code, big decimal discount, and expiry date, and build a Spring Data repository for operations on the coupon table.
Create a coupon rest controller in Spring Cloud exposing a post API to create coupons and a get API to retrieve by code, with Spring Data JPA findByCode in repository.
Test coupon service by running spring boot app and using postman to create a coupon via post to /coupons with code, discount, and expiry date, then fetch by /coupons/{code}.
Create the product service model and repository in Spring Cloud Fundamentals by defining a JPA entity with id, name, description, and price, and a repository interface extending JpaRepository<Product, Long>.
Create a product rest controller in Spring Cloud, map post /product, accept a product via @RequestBody, save to the database using the product repository, and plan coupon service integration later.
Configure the data source by accessing the application.properties of coupon services, copying the required values, pasting them into the target file, and saving.
Run the product service on port 9090, launch the Spring Boot app, and create a new product via the product API with Postman, verifying 200 OK and a database entry.
Register microservices with a Spring Cloud Eureka naming server to enable dynamic discovery, so services fetch URL details and ports using a unique application name via Eureka client.
Create a Eureka discovery server for microservice apps, add the spring cloud starter for Netflix Eureka, and note that the Eureka discovery client will register with this server.
Enable the Eureka server and configure its properties, including port 8761, while setting register and fetch registry to false for the server and true for client microservices.
Launch the Eureka server on port 8761 and verify it is up. No services are registered yet, as product and coupon services will register as discovery clients in upcoming lectures.
Add eureka client dependencies to the coupon and product services and update spring cloud dependency management to register these clients with the eureka server.
Register the coupon and product services with the Eureka server by enabling the Eureka client and configuring spring.application.name and the Eureka client url default zone to http://localhost:8761/eureka.
Start the Eureka server and run the coupon and product services to register as discovery clients, then verify they appear on the Eureka server after refresh.
Learn to connect a product service to a coupon service using declarative Feign clients in Spring Cloud, with Eureka for service discovery.
Add the spring cloud open feign maven dependency in the product service to call the coupon microservice, replacing the Netflix Eureka client and enabling rest clients with open feign.
Create a feign client interface annotated with @FeignClient to call the coupon service via a GET mapping with a path variable, deserializing the coupon JSON into a model.
Use the rest feign client in the product rest controller to call the coupon service and apply a discount to the product price before saving it.
Enable and test Feign client support in a Spring Cloud project. Wire the product and coupon services with Eureka discovery and validate discounts via a REST call using Postman.
Configure load balancing for the product and coupon services with Spring Cloud Load Balancer, run two coupon instances, and verify distribution across servers via the product service.
Explore Spring Cloud fundamentals and configure the API Gateway to enforce cross-cutting concerns such as security, tracing, service aggregation, and rate limits, routing microservice calls and enabling server-side load balancing.
Create a gateway project in Spring Tool Suite, add gateway and Eureka discovery client dependencies, configure Eureka properties, and plan routes for coupon and product services.
Configure the gateway routes for coupon and product microservices by editing application properties with route IDs, Eureka-backed URIs, and path predicates, so requests flow through the gateway to each service.
Start the api gateway, enable the eureka client, and route requests from postman on port 9095 through the gateway to the product and coupon microservices.
Leverage the API gateway to implement crosscutting concerns with custom filters that perform pre-processing and post-processing for security, tracing, and rate limits, using a gateway filter chain.
Explore how API gateway filters operate as global filters, implementing pre-processing and post-processing in a Spring reactive gateway, using the gateway filter chain to forward requests to microservices.
Explore resilience4j for spring boot to enable fault tolerance between microservices, and configure retries and fallbacks with application properties and actuator support to gracefully handle errors.
Configure resilience4j retries in a spring boot product service to retry coupon client calls with max attempts and wait duration, and observe the retry delay via the api gateway.
Use a retry annotation with a fallback method to handle persistent failures, returning a graceful dummy product and hiding the exception from the client.
Sample of the reviews:
This course is clearing the concept as we progress and we are getting to learn the intricacies of micro-service architecture. Great course to build your concept around the micro service world & Bharath is one of the finest instructor around. - Puneet Shrivastava
Great course: simple, clear and straight to the nitty-gritty. - Jose Maria Martinez Sanchez
This is a great course. Bharath goes through the elements of Spring Cloud with code examples. By the end of the course, you'll have an end-to-end reference implementation of Spring Cloud of your machine. I'll use it as a reference when I build Spring Cloud projects in the future. - Mike Bishop
All source code is available for download
Responsive Instructor - All questions answered within 24 hours
Professional video and audio recordings (check the free previews)
Are you a Spring Developer with Microservices background who is interested in quickly mastering the fundamentals of Spring Cloud then this course is for you.This course is also for those students who have completed my End To End Project Development course using spring boot.
Spring is the most widely used framework in the industry today. Looking at any java developer job posting you will see Spring Boot and Spring Cloud.This course is designed for experienced as well as complete beginners to learn the of Spring Cloud Fundamentals in easy steps.
You will start this course by creating two simple Microservice. You will then see how easy it is to use Spring Cloud components for the non functional requirements of your Microservices. You will
Use Eureka For Microservice Registration and Discovery
Implement Fault Tolerance for your Microservice using Hystrix
Create declarative Microservice REST client using Feign
Do client side load balancing using Ribbon
Use Proxy Gateways for cross cutting concerns
Make your Microservice applications fault tolerant using Hystrix
Enable Distributed Tracing through Sleuth
And More in Easy Steps