Spring Cloud Tutorial

Spring Cloud Tutorial thumbnail
20K
By Amit K Swain 10 March, 2018
spring-cloud

The rise in popularity of cloud-based architectures and the shift to implementing applications as series of focused microservices developed around bounded contexts has led to the discovery and rediscovery of patterns and techniques useful in designing distributed systems.

Netflix, a pioneer in the microservices space, has built many such tools. Eureka is a service registry, which registers all of a microservice’s instances and supplies each microservice with instance information to use in discovering others. Hystrix, the Hystrix Dashboard, and Turbine provide fault tolerance using circuit breakers and enable monitoring of circuits across microservices and instances.

Spring Cloud builds on Spring Boot by providing a bunch of libraries that enhance the behaviour of an application when added to the classpath.You can take advantage of the basic default behaviour to get started really quickly, and then when you need to, you can configure or extend to create a custom solution. The family of projects provided by Spring cloud ease the development of microservices using annotations.

Following is the maven dependency required to get started wih spring cloud.

<parent>
	<groupId>org.springframework.boot</groupId>
	<artifactId>spring-boot-starter-parent</artifactId>
	<version>2.0.0.M7</version>
</parent>
<dependencyManagement>
	<dependencies>
		<dependency>
			<groupId>org.springframework.cloud</groupId>
			<artifactId>spring-cloud-dependencies</artifactId>
			<version>Finchley.M7</version>
			<type>pom</type>
			<scope>import</scope>
		</dependency>
	</dependencies>
</dependencyManagement>
<dependencies>
	<dependency>
		<groupId>org.springframework.cloud</groupId>
		<artifactId>spring-cloud-starter-config</artifactId>
	</dependency>
	<dependency>
		<groupId>org.springframework.cloud</groupId>
		<artifactId>spring-cloud-starter-eureka</artifactId>
	</dependency>
</dependencies>

Note: We can use different community versions like Dalston and Camden instead of Finchley

Let's follow the articles below to explore more about the behaviour of Netflix stacks used by spring cloud.

Introduction to Microservices

MicroServices or Microservice Architecture is a distinct method of developing and designing software systems. The concept of a microservice originally crept into the software development community’s consciousness around 2014 and was a direct response to many of the challenges faced with old monlithic architecture.In this post we will focus on the crave of microservices.

Spring Cloud NetFlix Eureka

This tutorial is about spring cloud Netflix Eureka. we will be creating eureka discovery server and microservices that will itself register to the discovery server and the client that will use netflix client API to discover the service and consume the microservices exposed by the service with sample example.Hence, we will be developing 3 different spring boot application for each discovery server, service and client.Also, we wil take a look into default eureka dashboard and different useful information available in the dashboard.

Spring Netflix Zuul

In this tutorial, we will be discussing about how to route in cloud native apps to different services using spring netflix zuul proxy.We will have multiple micro services running and an API gateway that does intelligent routing through proxy based on the requested resource.We will be also discussing about setting up Zuul Filter to intercept all the request and perform some operations to all the requests that pass through the API gateway.

Spring Cloud Gateway

We will discuss Spring Cloud Gateway - a reactive Gateway built upon Project Reactor, Spring WebFlux, and Spring Boot 2.0. First, we will start with an introduction of Spring Cloud Gateway and then discuss the features of it that makes it the best fit as a cloud gateway. After that, we will look into the gateway flow with different examples of using predicates for routing, pre-filters, global filters to modify the request and response header and body along with Hystrix support.

Spring Cloud Gateway Example

In the last article, we looked into Spring Cloud Gateway and discussed its core concepts and capabilities as a non-blocking API Gateway. In this article, we will use those concepts to develop an end to end microservice based architecture application using spring cloud. In the process, we will use spring cloud gateway as a gateway provider, Netflix Eureka as a discovery server with circuit breaker pattern using Netflix Hystrix.

Spring Cloud Hystrix Example

In this tutorial, we will be discussing about creating self healing and fault tolerance services with circuit breaker pattern using Netflix Hystrix.We will be discussing about failures in a distributed system and how Netflix spring cloud Netflix hystrix helps to create such fault tolerance system using annotations such as @EnableCircuitBreaker, @HystrixCommand.At the end, we will enable hystrix dashboard within our example using @EnableHystrixDashboard.

Spring Cloud Configuration - Externalize Application Configuration

This tutorial is about spring cloud config.Here, we will take a look at how we can manage to serve and store distributed external configurations properties using spring cloud config across different applications for different environments such as dev, local, prod etc.First we will develop a simple cloud application to externalize application configurations properties using cloud config and then extend the same application to use discovery server to register the application, updating the configuration at runtime and encrypting and decrypting sensitive properties.

Refresh Property Config at Runtime in Spring Cloud Config

In this tutorial series of spring cloud config, we will be discussing about refreshing property configuration at run-time.We will be doing so using spring boot actuator /refresh endpoint.Also, we will take a look into refreshing @Value properties using @RefreshScope annotation.

Spring Cloud Netflix Feign

In this article we will discuss about the declarative HTTP client provided by Netflix i.e FeignIt has pluggable annotation support including Feign annotations and JAX-RS annotations provided by Spring cloud.Spring Cloud integrates Ribbon and Eureka to provide a load balanced HTTP client when using Feign.

Share

If You Appreciate This, You Can Consider:

We are thankful for your never ending support.

About The Author

author-image
I have a professional experience of 4.4 yrs as a Java developer. My Primary Skills include Java Tech Stacks like Spring ,Hibernate,JPA,Spring Boot, JDBC and Spring Rest. Besides that I am always keen to work Client Side technologies like JavaScript and Angular. Currently focusing on microservices architecture and CQRS.

Further Reading on Spring Cloud