Skip to main content

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...

1ntr0duct10n

 Hey folks, welcome to sem1c010n..!

If you're looking for perfect coding content, you're in the right place...!

We keep you excited every time with fresh content — dive in and get codified!

Stay tuned... keep coding ๐Ÿš€

Comments

Popular posts from this blog

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...

Mastering Java Streams: Smart Ways to Handle Strings Like a Pro

Working with strings is a daily task for Java developers. But if you're still stuck in loops and if-else blocks, it’s time to level up! ๐Ÿ’ช Java Streams offer a clean, expressive, and functional way to process strings—whether you're transforming, filtering, or analyzing them. In this blog, we’ll explore: ๐Ÿ› ️ Different ways to use streams on strings in Java ๐Ÿ’ผ Popular interview questions involving Java strings and streams Whether you're a beginner or an experienced developer preparing for interviews, this guide has you covered. ✨ Section 1: Different Approaches to Use Streams on Strings in Java Let’s look at how to apply Java Streams on strings using various real-world examples. 1. Convert a String to a List of Characters List<Character> characters = str.chars() .mapToObj(c -> (char) c) .collect(Collectors.toList()); ๐Ÿงพ Explanation: str.chars() returns an IntStream of character codes. .mapToObj(c -> (char) c) casts each int...

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...