Microservices with Spring Boot
A simple example of setting up a microservices system using Spring, Spring Boot and Spring Cloud.
Microservices enable massive systems to be developed from a collection of interconnected components. It implements loosely coupled processes rather than loosely coupled components at the process level, as Spring has always done at the component level.
For an example imagine there is a Movie Catelog API Application that the users wants to list the movies that they are watched and put a start rating on top of the movie. Whenever they enter their user ID it has to pull up all the movies that a particular user has watched and rated.
RestTemplate
Microservice architecture has many independent applications and some time it is needed that one application communicates with other application to do some operation. So if we want to communicate between two microservice then spring cloud provided us RestTemplate.
How to create a RestTemplate
Spring WebClient vs. RestTemplate
- One of the main differences is RestTemplate is synchronous and blocking When we do a rest call we need to wait till the response comes back to proceed further.
- When using the WebClient the caller need not wait till response comes back. Instead he will be notified when there is a response.
- WebClient supports asynchronous as well as synchronous calls. RestTemplate supports only synchronous calls.
Spring Cloud : Service Discovery with Eureka
Service Discovery
A distributed system is made up of a large number of services that communicate with one another to fulfill certain tasks. The process of one service dynamically discovering the network location of another service in order to connect with it is known as service discovery.
Eureka Server
Eureka is a REST based service which is primarily used for acquiring information about services that you would want to communicate with. This REST service is also known as Eureka Server. The Services that register in Eureka Server to obtain information about each other are called Eureka Clients.
Eureka Client
Any application that can discover services.






0 Comments