How to Trace Microservices Logs with Spring Cloud Sleuth and Zipkin

Introduction Here I am going to explain how to trace Spring Boot Microservices logs with Spring Cloud Sleuth and Zipkin Server. Spring Cloud Sleuth provides Spring Boot auto-configuration for distributed tracing. One of the problems most developers face difficulty of tracing logs as your microservices applications grow and requests propagate from one microservice to another microservice. So it could be quite part to try to figure out how a particular request travels through the application when you don’t have any idea regarding the implementation of microservices you are calling.

Continue

Spring Centralized Runtime Properties Configuration without refreshing the Client

Introduction This tutorial walks you through the process of consuming the configurations from the Spring cloud config server. So we will setup a config server and build a client application consumes the configuration on startup and then refreshes the configuration without restarting the client. Let’s say you have some configuration values which may be changed during runtime and it is not possible always to restart your application and change the configuration values. Here Spring configuration helps us to externalize our properties or configurations.

Continue

How to implement Circuit Breaker Pattern using Hystrix in Spring Cloud Gateway

Introduction We will see how to implement circuit breaker pattern using Hystrix in Spring Cloud Gateway. Hystrix is a library from Netflix that implements the circuit breaker pattern. The Hystrix GatewayFilter allows us to introduce circuit breakers to our gateway routes, protecting our services from cascading failures and allowing us to provide fallback responses in the event of downstream failures. To enable Hystrix GatewayFilters in our project, we need to add a dependency on spring-cloud-starter-netflix-hystrix from Spring Cloud Netflix.

Continue

Use load balancer name for Microservices instead of host, port for URI in Spring Cloud Gateway

Introduction Here we will see how to use load balancer name or service name for Microservices instead of host, port for URI while building API gateway using Spring Cloud Gateway – the tutorial example which we have created earlier. We will use the same tutorial to use load balancer name instead of URL, such as, http://localhost:9000, http://localhost:9001, etc. for the URI value in application.yml configuration file. The advantage of using the load balancer name is you don’t need to worry about the change of the internal URLs for the microservices.…

Continue

How to build Spring Cloud Gateway for Microservices

In this tutorial we will build Spring Cloud Gateway for Microservices built using Spring Boot framework. Spring Cloud Gateway aims to provide a simple, yet effective way to route to APIs and provide cross cutting concerns to them such as: security, monitoring/metrics, and resiliency. Spring Cloud Gateway aims to provide a simple, yet effective way to route to APIs. When it receives request, Spring Cloud Gateway forwards it to a Gateway Handler Mapping, which determines what should be done with requests matching a specific route.

Continue

Event Driven Streaming using Spring Cloud Stream and Apache Kafka

In this tutorial we will see an example of event driven streaming using Spring Cloud Stream and Apache Kafka streaming platform. How do we deal with some events, such as, a new user has registered to a portal, an order was placed, a file has been uploaded etc? Let’s say when an order was placed then we need a call to process payment, a call to reserve inventory, a call to begin the process of packaging, picking and shipping the product. For a few orders it’s not a big deal…

Continue