Spring Cloud
Hi Friends!!!, It has been really long since last I wrote for Spring HATEOAS, and along with that I really want to apologize for not completing it and soon I am going to post all my finding on that.
But before going into that I thought why not Refurbish ourseleves with something new, something really interesting. Here it is, Spring Cloud
Spring is always considered as an onestop need for all the requirements, and when I say that I mean in each and every aspect, which makes Spring essentially an ecosystem.
Spring Cloud is no exception to that.
Spring Cloud provides tools for developers to quickly build some of the common patterns in distributed systems.
1) configuration management
2) service discovery
3) circuit breakers
4) intelligent routing
5) micro-proxy
6) control bus
7) one-time tokens
8) global locks
9) leadership election
10) distributed sessions
11) Cluster state.
With the MICROSERVICES gaining popularity at a fast pace, because of its architectural flexibility and integration with varies other alien entities and Spring providing support for that too makes the whole picture really bewildering. This post is centered towards exploring one of the very basic yet essential feature of Spring Cloud i.e. Service Registration, Service Discovery and then invoking the same.
By service, I most prominently imply MICROSERVICES.
For Service Registration, Service Discovery there are various platforms that Spring provides support for:
1) Eureka
2) Consul
3) ZooKeeper (With Apache Curator API wrapping the core Zookeeper services and providing a layer of abstraction is really fascinating.)
Here our objective is to:
1) Start a Eureka Server.
2) Create a Spring Based Microservice and register the same in Eureka.
3) Create a Spring Based Clientand register and the same in Eureka.
4) Discover the service from the Client and invoke one of the services with Spring Cloud Aware RestTemplate, which has an inbuilt load balancing software client Ribbon, which comes into operation when multiple instances of the same service gets registered in Eureka. Spring Cloud does all the magic with Spring Boot when RestTemplate gets Autowired. (Though this plot is out of scope for the present post and surely will be taken up with vigor.
5) Create a Spring Based Client using Feign (This feature too is a candidate for subsequent curiosity) .
We are going to split this post in few co-related sections so that we do not clutter up all things at once.
So,lets start Now!!!
We have at present 3 services:
1) Spring-Cloud-Eureka
2) Spring-Cloud-AuthService
3) Spring-Cloud-Client
Each of these 3 services are Spring Boot based as Spring Cloud has a facile integration with Spring Boot.
As far as the operation perspective is concerned:
Spring-Cloud-Eureka module just starts the Eureka Server (EurekaStarter.java) at the port specified in application.yml. This properties file has all the other essential configuration.
Once the Eureka Server is up and in running status it is ready for service registration and discovery as required. We can access the server console at:
http://localhost:8763/
In the section Instances currently registered with Eureka, there are presently no services registered, but once services gets registered they will start appearing in this section.
We will soon see how?
Spring-Cloud-AuthService is a Spring Boot based web application.The gripping nature of this service is thatonce the service is up it registers itself with the Eureka (which is already in running status) as per the configuration details mentioned in authserver-config.yml.
Spring-Cloud-Client is the client that looks up the services registered in Eureka and invokes them with the help of Spring Cloud Aware RestTemplate .The client also needs to register itself with Eureka to get the references of the already registered services.
The configuration details are mentioned in application-dev.yml, bootstrap.yml and client-config.yml.
As the services gets registered themselves in Eureka, we can view all the registered services in the console.
So it appeared :-).
I have uploaded my code base at GITHUB [Please Note: Every service can be started from the command prompt with: mvn clean install spring-boot:run]
This is indeed a very short and basic beginning to Spring Cloud but really an overwhelming experience for me.
In my next post, the stress will be to explore Feign Client, multiple instance registration of the same service (to see the load balancer in Action) and Configuration Management for Cloud based application and a brief introduction to the “GATEKEEPER”, the MIGHTY “ZUUL”.
But before going into that I thought why not Refurbish ourseleves with something new, something really interesting. Here it is, Spring Cloud
Spring is always considered as an onestop need for all the requirements, and when I say that I mean in each and every aspect, which makes Spring essentially an ecosystem.
Spring Cloud is no exception to that.
Spring Cloud provides tools for developers to quickly build some of the common patterns in distributed systems.
1) configuration management
2) service discovery
3) circuit breakers
4) intelligent routing
5) micro-proxy
6) control bus
7) one-time tokens
8) global locks
9) leadership election
10) distributed sessions
11) Cluster state.
With the MICROSERVICES gaining popularity at a fast pace, because of its architectural flexibility and integration with varies other alien entities and Spring providing support for that too makes the whole picture really bewildering. This post is centered towards exploring one of the very basic yet essential feature of Spring Cloud i.e. Service Registration, Service Discovery and then invoking the same.
By service, I most prominently imply MICROSERVICES.
For Service Registration, Service Discovery there are various platforms that Spring provides support for:
1) Eureka
2) Consul
3) ZooKeeper (With Apache Curator API wrapping the core Zookeeper services and providing a layer of abstraction is really fascinating.)
Here our objective is to:
1) Start a Eureka Server.
2) Create a Spring Based Microservice and register the same in Eureka.
3) Create a Spring Based Clientand register and the same in Eureka.
4) Discover the service from the Client and invoke one of the services with Spring Cloud Aware RestTemplate, which has an inbuilt load balancing software client Ribbon, which comes into operation when multiple instances of the same service gets registered in Eureka. Spring Cloud does all the magic with Spring Boot when RestTemplate gets Autowired. (Though this plot is out of scope for the present post and surely will be taken up with vigor.
5) Create a Spring Based Client using Feign (This feature too is a candidate for subsequent curiosity) .
We are going to split this post in few co-related sections so that we do not clutter up all things at once.
So,lets start Now!!!
We have at present 3 services:
1) Spring-Cloud-Eureka
2) Spring-Cloud-AuthService
3) Spring-Cloud-Client
Each of these 3 services are Spring Boot based as Spring Cloud has a facile integration with Spring Boot.
As far as the operation perspective is concerned:
Spring-Cloud-Eureka module just starts the Eureka Server (EurekaStarter.java) at the port specified in application.yml. This properties file has all the other essential configuration.
Once the Eureka Server is up and in running status it is ready for service registration and discovery as required. We can access the server console at:
http://localhost:8763/
In the section Instances currently registered with Eureka, there are presently no services registered, but once services gets registered they will start appearing in this section.
We will soon see how?
Spring-Cloud-AuthService is a Spring Boot based web application.The gripping nature of this service is thatonce the service is up it registers itself with the Eureka (which is already in running status) as per the configuration details mentioned in authserver-config.yml.
Spring-Cloud-Client is the client that looks up the services registered in Eureka and invokes them with the help of Spring Cloud Aware RestTemplate .The client also needs to register itself with Eureka to get the references of the already registered services.
The configuration details are mentioned in application-dev.yml, bootstrap.yml and client-config.yml.
As the services gets registered themselves in Eureka, we can view all the registered services in the console.
So it appeared :-).
I have uploaded my code base at GITHUB [Please Note: Every service can be started from the command prompt with: mvn clean install spring-boot:run]
This is indeed a very short and basic beginning to Spring Cloud but really an overwhelming experience for me.
In my next post, the stress will be to explore Feign Client, multiple instance registration of the same service (to see the load balancer in Action) and Configuration Management for Cloud based application and a brief introduction to the “GATEKEEPER”, the MIGHTY “ZUUL”.
Comments
Post a Comment