Skip to main content

Posts

Showing posts from May, 2025

Retry module - Resilience4j

as we discussed about circuit breaker module from resilience4j earlier, let's see what Retry module actually offers What is Retry in Resilience4j? this module offers ways of handling failure transaction by automatically retrying those transactions as per properties we configure. let's check how it works in this article. below code shows, how we can add retry annotation to our feign client Note: There is no need to add a fallbackMethod in the @Retry annotation if it is already defined in @CircuitBreaker . @GetMapping("/users/{userId}/albums") @Retry(name="album-service") @CircuitBreaker(name = "album-service", fallbackMethod = "getAlbumsFallbackMethod") public List<AlbumResponseModel> getAlbums(@PathVariable String userId); default List<AlbumResponseModel> getAlbumsFallbackMethod(String userId, Throwable exception) { System.out.println("user id" + userId); System.out.println("exc...

Retry module - Resilience4j

as we discussed about circuit breaker module from resilience4j earlier, let's see what Retry module actually offers What is Retry in Resilience4j? this module offers ways of handling failure transaction by automatically retrying those transactions as per properties we configure. let's check how it works in this article. below code shows, how we can add retry annotation to our feign client Note: There is no need to add a fallbackMethod in the @Retry annotation if it is already defined in @CircuitBreaker . @GetMapping("/users/{userId}/albums") @Retry(name="album-service") @CircuitBreaker(name = "album-service", fallbackMethod = "getAlbumsFallbackMethod") public List<AlbumResponseModel> getAlbums(@PathVariable String userId); default List<AlbumResponseModel> getAlbumsFallbackMethod(String userId, Throwable exception) { System.out.println("user id" + userId); System.out.println("exc...

circuit breaker and its events - resilience4j

In this article, let's discuss about circuit breaker, its properties, and some of its events. What is a Circuit Breaker? It is a fault tolerance mechanism used in microservices. It is a part of Resilience4j . Circuit breaker is used to avoid multiple calls to non-responding microservices, preventing cascading failures. How to Use Circuit Breaker To use circuit breaker, add the below dependencies in your pom.xml : <dependency> <groupId>io.github.resilience4j<groupId> <artifactId>resilience4j-spring-boot2<artifactId> <dependency> <dependency> <groupId>org.springframework.boot<groupId> <artifactId>spring-boot-starter-aop<artifactId> <dependency> Assuming we are using Feign Client for communication between microservices, here's an example from a user microservice calling an album microservice: @FeignClient(name = "album-service") public interface Albu...