{"id":39594,"date":"2025-06-13T20:53:43","date_gmt":"2025-06-13T15:23:43","guid":{"rendered":"https:\/\/mobisoftinfotech.com\/resources\/?p=39594"},"modified":"2025-11-04T10:36:34","modified_gmt":"2025-11-04T05:06:34","slug":"resilience4j-circuit-breaker-retry-bulkhead-spring-boot","status":"publish","type":"post","link":"https:\/\/mobisoftinfotech.com\/resources\/blog\/microservices\/resilience4j-circuit-breaker-retry-bulkhead-spring-boot","title":{"rendered":"Resilience4j Circuit Breaker Tutorial along with Retry &amp; Bulkhead patterns for Spring Boot Microservices"},"content":{"rendered":"<h2 class=\"wp-block-heading\"><strong>Introduction<\/strong><\/h2>\n\n\n\n<p>Microservices architecture has become the go-to approach for building scalable, modular, and independently deployable systems. By breaking down a system into smaller, loosely coupled services, teams can innovate faster and scale components independently.&nbsp;<\/p>\n\n\n\n<p>However, while microservices offer clear architectural benefits, they also introduce complexity, particularly around communication between services. These systems depend heavily on network interactions, making them susceptible to latency issues and partial failures.<\/p>\n\n\n\n<p>This is where resilience in microservices becomes essential. Building fault tolerant microservices means anticipating failures and mitigating their impact to ensure system stability and a smooth user experience.<\/p>\n\n\n\n<p>To address these concerns, tools like Resilience4j have emerged. It\u2019s a lightweight Java resilience library designed for functional programming and integrates seamlessly with Spring Boot. Resilience4j offers several powerful microservices resilience patterns to improve service-to-service reliability, including the Circuit Breaker pattern, Retry mechanism, and the Bulkhead pattern in microservices.<\/p>\n\n\n\n<p>Tools like Resilience4j align well with efforts focused on<a href=\"https:\/\/mobisoftinfotech.com\/services\/digital-transformation-services?utm_source=blog&amp;utm_campaign=resilience4j-circuit-breaker-retry-bulkhead-spring-boot\"> modernizing applications with digital transformation<\/a>, enabling fault-tolerant service design in cloud environments.<\/p>\n\n\n\n<p>For a broader<a href=\"https:\/\/mobisoftinfotech.com\/resources\/blog\/understanding-microservices-human-guide?utm_source=blog&amp;utm_campaign=resilience4j-circuit-breaker-retry-bulkhead-spring-boot\"> introduction to microservices<\/a> and their role in modern software architecture, it&#8217;s essential to understand how they evolved from traditional monolithic systems.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Challenges in Microservices<\/strong><\/h2>\n\n\n\n<p>While monolithic applications operate largely within a single process, microservices rely on distributed communication, usually over HTTP or messaging systems. This introduces new classes of failure that must be accounted for:<\/p>\n\n\n\n<h3 class=\"wp-block-heading h3-list\"><strong>Latency Overhead<\/strong><\/h3>\n\n\n\n<p>In a monolith, method calls are in-process and virtually instantaneous. In microservices, these calls occur over the network, leading to increased latency. Even a small delay in a downstream service can ripple through the system, resulting in cascading latency and degraded user experience.<\/p>\n\n\n\n<h3 class=\"wp-block-heading h3-list\"><strong>Dependency Failures<\/strong><\/h3>\n\n\n\n<p>Each microservice typically depends on one or more downstream services. If a dependent service is slow or unavailable, it can trigger timeouts or exceptions. Left unchecked, this can lead to resource exhaustion, where threads or connections are consumed waiting on failed services, resulting in cascading failures that impact the whole system.<\/p>\n\n\n\n<p>These challenges underscore the need for resilience patterns in Java-based microservices. By integrating techniques such as the Resilience4j Circuit Breaker, Retry pattern in microservices, and Bulkhead pattern, we can significantly enhance the fault tolerance and robustness of our Spring Boot applications.<\/p>\n\n\n\n<p>These practices align closely with core<a href=\"https:\/\/mobisoftinfotech.com\/resources\/blog\/essential-principles-spring-boot-microservices?utm_source=blog&amp;utm_campaign=resilience4j-circuit-breaker-retry-bulkhead-spring-boot\"> Spring Boot microservices principles<\/a> that guide scalable, reliable, and maintainable service development.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/mobisoftinfotech.com\/services\/software-development-company?utm_source=blog_cta&amp;utm_campaign=resilience4j-circuit-breaker-retry-bulkhead-spring-boot\"><noscript><img decoding=\"async\" width=\"855\" height=\"363\" src=\"https:\/\/mobisoftinfotech.com\/resources\/wp-content\/uploads\/2025\/06\/custom-software-development-solutions.png\" alt=\" Software development isn\u2019t one-size-fits-all\" class=\"wp-image-39605\" title=\"Custom Software Development CTA\"><\/noscript><img decoding=\"async\" width=\"855\" height=\"363\" src=\"data:image\/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%20855%20363%22%3E%3C%2Fsvg%3E\" alt=\" Software development isn\u2019t one-size-fits-all\" class=\"wp-image-39605 lazyload\" title=\"Custom Software Development CTA\" data-src=\"https:\/\/mobisoftinfotech.com\/resources\/wp-content\/uploads\/2025\/06\/custom-software-development-solutions.png\"><\/a><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Key Benefits of Resilience Patterns<\/strong><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>1. Prevent Cascading Failures<\/strong><\/h3>\n\n\n\n<p>The Circuit Breaker resilience4j implementation stops repeated calls to failing services, protecting the system from overload and minimizing downstream impact.<\/p>\n\n\n\n<p>For example, if a payment service in an e-commerce app is slow, the circuit breaker stops further calls to it temporarily, ensuring the frontend remains responsive and other services aren&#8217;t affected. This allows the system to degrade gracefully while the failing service recovers.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>2. Isolate Resource Contention<\/strong><\/h3>\n\n\n\n<p>The bulkhead pattern in microservices ensures that one service or thread pool doesn&#8217;t monopolize resources, allowing other parts of the system to continue functioning.<\/p>\n\n\n\n<p>For example, if a reporting module starts consuming too many threads, a bulkhead can limit its concurrency, ensuring that core features like order placement in an e-commerce app remain unaffected and responsive.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>3. Automatically Recover from Transient Failures<\/strong><\/h3>\n\n\n\n<p>The retry pattern in microservices automatically retries failed calls a configured number of times before giving up. It handles transient faults like temporary network issues or backend unavailability.<\/p>\n\n\n\n<p>For example, if a backend service intermittently fails due to a brief timeout or momentary unavailability, retrying the request can often succeed without impacting the user experience. This reduces error rates and improves system reliability without requiring manual intervention, allowing services to self-heal from transient problems.<\/p>\n\n\n\n<p>Combining resilience patterns with<a href=\"https:\/\/mobisoftinfotech.com\/services\/devops?utm_source=blog&amp;utm_campaign=resilience4j-circuit-breaker-retry-bulkhead-spring-boot\"> DevOps automation and monitoring<\/a> ensures better observability and proactive failure management across microservices.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Key Resilience Patterns<\/strong><\/h2>\n\n\n\n<figure class=\"wp-block-image size-full\"><noscript><img decoding=\"async\" width=\"855\" height=\"279\" src=\"https:\/\/mobisoftinfotech.com\/resources\/wp-content\/uploads\/2025\/06\/visualizing-resilience4j-patterns.png\" alt=\"visualize circuit breaker retry and bulkhead patterns\" class=\"wp-image-39606\" title=\"Visualizing Resilience4j Patterns\"><\/noscript><img decoding=\"async\" width=\"855\" height=\"279\" src=\"data:image\/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%20855%20279%22%3E%3C%2Fsvg%3E\" alt=\"visualize circuit breaker retry and bulkhead patterns\" class=\"wp-image-39606 lazyload\" title=\"Visualizing Resilience4j Patterns\" data-src=\"https:\/\/mobisoftinfotech.com\/resources\/wp-content\/uploads\/2025\/06\/visualizing-resilience4j-patterns.png\"><\/figure>\n\n\n\n<p>Modern microservices must anticipate and gracefully handle failure scenarios. Resilience4j examples showcase how the library enables services to recover from latency, failures, and resource bottlenecks using focused resilience patterns in microservices.<\/p>\n\n\n\n<p>The three core patterns, Circuit Breaker, Retry, and Bulkhead, work together to build highly resilient microservices in Java.<\/p>\n\n\n\n<h3 class=\"wp-block-heading h3-list\"><strong>Circuit Breaker<\/strong><\/h3>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>What is a Circuit Breaker?<\/strong><\/h4>\n\n\n\n<p>The Circuit Breaker pattern in microservices prevents a service from repeatedly calling a failing downstream service. Instead of overwhelming the system with retries or blocking threads, it opens the circuit after a failure threshold is reached. This fail-fast mechanism helps avoid cascading failures and gives failing services time to recover.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>Why It\u2019s Important<\/strong><\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Prevents cascading failures by stopping calls to unhealthy services.<\/li>\n\n\n\n<li>Helps recover gracefully from transient issues.<\/li>\n\n\n\n<li>Reduces system load during failure periods.<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>Circuit Breaker States<\/strong><\/h4>\n\n\n\n<p>A Circuit Breaker in Resilience4j transitions through three states to manage backend failures:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Closed: <\/strong>All requests are allowed through. The circuit breaker monitors failures. If the failure rate exceeds the configured threshold, it opens the circuit.<\/li>\n\n\n\n<li><strong>Open: <\/strong>All requests are rejected immediately. This state prevents the system from sending load to a failing service. The circuit remains open for the configured wait duration.<\/li>\n\n\n\n<li><strong>Half-Open: <\/strong>After the wait period, a limited number of requests are allowed through. If they succeed, the circuit closes. If failures continue, the circuit returns to the open state, often with a longer wait period.<\/li>\n<\/ul>\n\n\n\n<p>This Resilience4j configuration ensures unstable services don\u2019t degrade the system and enables automatic recovery without manual intervention.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><noscript><img decoding=\"async\" width=\"1200\" height=\"578\" src=\"https:\/\/mobisoftinfotech.com\/resources\/wp-content\/uploads\/2025\/06\/circuit-breaker-state-machine.png\" alt=\"circuit breaker pattern in microservices using resilience4j\" class=\"wp-image-39607\" title=\"Circuit Breaker State Transitions\"><\/noscript><img decoding=\"async\" width=\"1200\" height=\"578\" src=\"data:image\/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%201200%20578%22%3E%3C%2Fsvg%3E\" alt=\"circuit breaker pattern in microservices using resilience4j\" class=\"wp-image-39607 lazyload\" title=\"Circuit Breaker State Transitions\" data-src=\"https:\/\/mobisoftinfotech.com\/resources\/wp-content\/uploads\/2025\/06\/circuit-breaker-state-machine.png\"><\/figure>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>Key Circuit Breaker Configuration Properties in Resilience4j<\/strong><\/h4>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>slidingWindowSize<br><\/strong>Defines the number of recent calls considered for failure rate calculation.<br>Default: 100<br>Example: <code>slidingWindowSize=5<\/code><br>Smaller values (e.g., 5) make the circuit breaker more sensitive to recent changes.<br><\/li>\n\n\n\n<li><strong>failureRateThreshold<br><\/strong>Sets the percentage of failed calls required to open the circuit breaker.<br>Default: 50%<br>Example: <code>failureRateThreshold=50<\/code><br>If 50% of recent calls fail, the circuit breaker opens. A higher threshold makes it more lenient.<br><\/li>\n\n\n\n<li><strong>waitDurationInOpenState<br><\/strong>Specifies how long the circuit breaker stays open before transitioning to half-open state.<br>Default: 60 seconds<br>Example: <code>waitDurationInOpenState=10s<\/code><br>After opening, it remains open for the specified time before testing with a limited number of requests.<br><\/li>\n\n\n\n<li><strong>permittedNumberOfCallsInHalfOpenState<br><\/strong>Defines how many calls are allowed in the half-open state to test backend recovery.<br>Default: 10<br>Example: <code>permittedNumberOfCallsInHalfOpenState=2<\/code><br>Fewer calls (e.g., 2) help evaluate if the backend has recovered before returning to a closed state.<br><\/li>\n\n\n\n<li><strong>minimumNumberOfCalls<br><\/strong>Specifies the minimum number of calls before evaluating whether the circuit breaker should open.<br>Default: 100<br>Example: <code>minimumNumberOfCalls=5<\/code><br>Prevents premature opening when there aren&#8217;t enough calls to assess failure rate.<br><\/li>\n\n\n\n<li><strong>automaticTransitionFromOpenToHalfOpenEnabled<br><\/strong>If true, the circuit breaker automatically transitions from open to half-open state after the wait duration.<br>Default: true<br>Example: <code>automaticTransitionFromOpenToHalfOpenEnabled=true<\/code><br>Disabling this requires manual intervention for state transitions.<\/li>\n<\/ol>\n\n\n\n<h3 class=\"wp-block-heading h3-list\"><strong>Retry<\/strong><\/h3>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>What is a Retry Pattern?<\/strong><\/h4>\n\n\n\n<p>Retry is a resilience pattern in microservices used to handle transient faults, temporary glitches such as network hiccups or, a temporarily overloaded service. Instead of failing on the first attempt, it automatically re-attempts the call after a delay, increasing the likelihood of success. This retry pattern in microservices is often implemented using libraries like Resilience4j in Spring Boot.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>Why It\u2019s Important<\/strong><\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Handles intermittent issues that may resolve quickly.<\/li>\n\n\n\n<li>Improves system robustness without manual retries.<\/li>\n\n\n\n<li>Helps smooth out temporary spikes in failure rates.<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>Key Retry Configuration Properties in Resilience4j<\/strong><\/h4>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>maxAttempts<br><\/strong>Defines the maximum number of attempts for a call, including the initial call plus retries.<br>Default: 3<br>Example: <code>maxAttempts=3<\/code><br>This means the call will be tried up to 3 times before giving up. If the first attempt fails (due to an exception or specific failure conditions), Resilience4j will automatically retry according to the configured policy.<\/li>\n\n\n\n<li><strong>waitDuration<br><\/strong>Specifies the fixed wait time between retry attempts.<br>Default: 500ms<br>Example: <code>waitDuration=2s<\/code><br>After a failed call, Resilience4j waits for this duration before trying again. Increasing this delay can help reduce the load on a struggling downstream service and give it time to recover.<\/li>\n<\/ol>\n\n\n\n<p>To further improve fault tolerance, resilience4j retry supports backoff strategies like exponential or random delays, helping avoid synchronized retries from multiple services that could lead to spikes in load.<\/p>\n\n\n\n<p><strong>Best Practice<\/strong>: Combine Retry with Circuit Breaker. Retry alone may exacerbate failures by increasing load; Circuit Breaker can guard against retry storms.<\/p>\n\n\n\n<h3 class=\"wp-block-heading h3-list\"><strong>Bulkhead<\/strong><\/h3>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>What is a Bulkhead Pattern?<\/strong><\/h4>\n\n\n\n<p>Inspired by ship design, the bulkhead pattern in microservices limits the number of concurrent requests to a service or resource. Just as watertight compartments prevent an entire ship from sinking, resilience patterns in Java, like bulkheads, prevent failures in one part of a system from cascading.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>Why it&#8217;s important<\/strong><\/h4>\n\n\n\n<p>Without bulkheads, a slow or failing dependency can monopolize system resources like threads or database connections. This often results in a complete system outage. The Resilience4j bulkhead pattern helps isolate failures and maintain system responsiveness by limiting the scope of impact.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>Key Bulkhead Configuration Properties in Resilience4j<\/strong><\/h4>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>maxConcurrentCalls<br><\/strong>Defines the maximum number of concurrent calls allowed at any given time.<br>Default: 25<br>Example: <code>maxConcurrentCalls=3<\/code><br>This limit ensures that only the specified number of calls (e.g., 3) are processed concurrently. Additional calls are either rejected immediately (if maxWaitDuration=0) or wait for a free spot.<br><\/li>\n\n\n\n<li><strong>maxWaitDuration<br><\/strong>Specifies how long a call should wait to acquire a permit before being rejected.<br>Default: 0 (no wait)<br>Example: <code>maxWaitDuration=500ms<\/code><br>When <code>maxWaitDuration &gt; 0<\/code>, excess calls will wait for an available spot, up to the specified duration. This reduces immediate rejections but may increase latency when the system is under heavy load.<\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Integrating Resilience4j in a Spring Boot Application<\/strong><\/h2>\n\n\n\n<p>To demonstrate this, we\u2019ll create two Spring Web applications: one serving as the frontend aggregator and the other as a fragile backend service.<\/p>\n\n\n\n<p>The frontend aggregator will be responsible for making HTTP calls to the backend, and it will incorporate Resilience4j to showcase the use of Circuit Breaker, Retry and Bulkhead patterns along with optional fallback methods to demonstrate graceful handling of the scenarios.<\/p>\n\n\n\n<p>The backend service, for simplicity, will expose a basic API endpoint that simulates responses introducing delays and failures to effectively test the resilience mechanisms in action.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Frontend Application Setup :<\/strong><\/h3>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>Dependencies and configuration&nbsp;<\/strong><\/h4>\n\n\n\n<p>First, need to include the necessary dependencies in your `pom.xml` if you\u2019re using Maven.<\/p>\n\n\n\n<p>Certain annotations from Resilience4j library depend on Spring AOP to work. So include Spring AOP dependency as well.<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-1\" data-shcb-language-name=\"HTML, XML\" data-shcb-language-slug=\"xml\"><span><code class=\"hljs language-xml\"><span class=\"hljs-comment\">&lt;!-- Spring Boot Web --&gt;<\/span>\n<span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">dependency<\/span>&gt;<\/span>\n \t<span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">groupId<\/span>&gt;<\/span>org.springframework.boot<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">groupId<\/span>&gt;<\/span>\n \t<span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">artifactId<\/span>&gt;<\/span>spring-boot-starter-web<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">artifactId<\/span>&gt;<\/span>\n<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">dependency<\/span>&gt;<\/span>\n\n<span class=\"hljs-comment\">&lt;!-- Resilience4j integration for Spring Boot 3 --&gt;<\/span>\n<span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">dependency<\/span>&gt;<\/span>\n \t<span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">groupId<\/span>&gt;<\/span>io.github.resilience4j<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">groupId<\/span>&gt;<\/span>\n \t<span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">artifactId<\/span>&gt;<\/span>resilience4j-spring-boot3<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">artifactId<\/span>&gt;<\/span>\n \t<span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">version<\/span>&gt;<\/span>2.1.0<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">version<\/span>&gt;<\/span> <span class=\"hljs-comment\">&lt;!-- Or the latest stable --&gt;<\/span>\n<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">dependency<\/span>&gt;<\/span>\n\n<span class=\"hljs-comment\">&lt;!-- Required for annotations like @CircuitBreaker, @Bulkhead --&gt;<\/span>\n<span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">dependency<\/span>&gt;<\/span>\n \t<span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">groupId<\/span>&gt;<\/span>org.springframework.boot<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">groupId<\/span>&gt;<\/span>\n \t<span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">artifactId<\/span>&gt;<\/span>spring-boot-starter-aop<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">artifactId<\/span>&gt;<\/span>\n<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">dependency<\/span>&gt;<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-1\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">HTML, XML<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">xml<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>And for Gradle&nbsp;<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-2\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript\"><span class=\"hljs-comment\">\/\/ Spring Boot Web<\/span>\nimplementation <span class=\"hljs-string\">'org.springframework.boot:spring-boot-starter-web'<\/span>\n\n<span class=\"hljs-comment\">\/\/ Resilience4j Spring Boot 3 support<\/span>\nimplementation <span class=\"hljs-string\">'io.github.resilience4j:resilience4j-spring-boot3:2.1.0'<\/span>\n\n<span class=\"hljs-comment\">\/\/ Required for annotations like @CircuitBreaker, @Bulkhead<\/span>\nimplementation <span class=\"hljs-string\">'org.springframework.boot:spring-boot-starter-aop'<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-2\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>In the application.properties file, we need to define all the configurations required for the circuit breaker, bulkhead.<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-3\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\">spring.application.name=aggregator\nserver.port=<span class=\"hljs-number\">8080<\/span>\nbackend.service.url=http:<span class=\"hljs-comment\">\/\/localhost:8081\/data<\/span>\n<span class=\"hljs-comment\"># Resilience4j - Circuit Breaker with name demoCircuitBreaker<\/span>\nresilience4j.circuitbreaker.instances.demoCircuitBreaker.slidingWindowSize=<span class=\"hljs-number\">5<\/span>\nresilience4j.circuitbreaker.instances.demoCircuitBreaker.failureRateThreshold=<span class=\"hljs-number\">50<\/span>\nresilience4j.circuitbreaker.instances.demoCircuitBreaker.waitDurationInOpenState=<span class=\"hljs-number\">10<\/span>s\nresilience4j.circuitbreaker.instances.demoCircuitBreaker.permittedNumberOfCallsInHalfOpenState=<span class=\"hljs-number\">2<\/span>\nresilience4j.circuitbreaker.instances.demoCircuitBreaker.minimumNumberOfCalls=<span class=\"hljs-number\">5<\/span>\nresilience4j.circuitbreaker.instances.demoCircuitBreaker.automaticTransitionFromOpenToHalfOpenEnabled=<span class=\"hljs-keyword\">true<\/span>\n\n<span class=\"hljs-comment\"># Resilience4j - retry with name demoCircuitBreaker<\/span>\nresilience4j.retry.instances.demoRetry.maxAttempts=<span class=\"hljs-number\">3<\/span>\nresilience4j.retry.instances.demoRetry.waitDuration=<span class=\"hljs-number\">2<\/span>s\n<span class=\"hljs-comment\"># Resilience4j - Bulkhead with name demoBulkhead<\/span>\n<span class=\"hljs-comment\">#Only 3 concurrent calls are allowed.<\/span>\n<span class=\"hljs-comment\">#Any 4th+ call that comes in at the same time will be immediately rejected.<\/span>\nresilience4j.bulkhead.instances.demoBulkhead.maxConcurrentCalls=<span class=\"hljs-number\">3<\/span>\nresilience4j.bulkhead.instances.demoBulkhead.maxWaitDuration=<span class=\"hljs-number\">0<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-3\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>If you are using application.yml :&nbsp;<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-4\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript\">spring:\n application:\n   name: aggregator\n\n<span class=\"hljs-attr\">server<\/span>:\n port: <span class=\"hljs-number\">8080<\/span>\n\n<span class=\"hljs-attr\">backend<\/span>:\n  service:\n    url: http:<span class=\"hljs-comment\">\/\/localhost:8081\/data<\/span>\n\nresilience4j:\n circuitbreaker:\n   instances:\n     demoCircuitBreaker:\n       slidingWindowSize: <span class=\"hljs-number\">5<\/span>\n       <span class=\"hljs-attr\">failureRateThreshold<\/span>: <span class=\"hljs-number\">50<\/span>\n       <span class=\"hljs-attr\">waitDurationInOpenState<\/span>: <span class=\"hljs-number\">10<\/span>s\n       <span class=\"hljs-attr\">permittedNumberOfCallsInHalfOpenState<\/span>: <span class=\"hljs-number\">2<\/span>\n       <span class=\"hljs-attr\">minimumNumberOfCalls<\/span>: <span class=\"hljs-number\">5<\/span>\n       <span class=\"hljs-attr\">automaticTransitionFromOpenToHalfOpenEnabled<\/span>: <span class=\"hljs-literal\">true<\/span>\n \n <span class=\"hljs-attr\">retry<\/span>:\n   instances:\n     demoRetry:\n       maxAttepts: <span class=\"hljs-number\">3<\/span>\n       <span class=\"hljs-attr\">waitDuration<\/span>: <span class=\"hljs-number\">2<\/span>s\n\n <span class=\"hljs-attr\">bulkhead<\/span>:\n   instances:\n     demoBulkhead:\n       maxConcurrentCalls: <span class=\"hljs-number\">3<\/span>\n       <span class=\"hljs-attr\">maxWaitDuration<\/span>: <span class=\"hljs-number\">0<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-4\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h4 class=\"wp-block-heading\"><strong>Controller implementation with resilience annotations<\/strong><\/h4>\n\n\n\n<p>Define a controller with endpoints that invoke the backend service API, incorporating resilience mechanisms such as CircuitBreaker, Retry and Bulkhead as configured in the application properties, to handle potential failures gracefully with fallback methods. We have used RestTemplate to make the API call to the backend service.&nbsp;<\/p>\n\n\n\n<p>In order to simulate concurrent calls to an API in case of bulkhead, we have added delay.<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-5\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript\"><span class=\"hljs-keyword\">import<\/span> org.slf4j.Logger;\n<span class=\"hljs-keyword\">import<\/span> org.slf4j.LoggerFactory;\n<span class=\"hljs-keyword\">import<\/span> org.springframework.web.bind.annotation.GetMapping;\n<span class=\"hljs-keyword\">import<\/span> org.springframework.web.bind.annotation.RestController;\n<span class=\"hljs-keyword\">import<\/span> org.springframework.web.client.RestTemplate;\n<span class=\"hljs-keyword\">import<\/span> io.github.resilience4j.bulkhead.annotation.Bulkhead;\n<span class=\"hljs-keyword\">import<\/span> io.github.resilience4j.circuitbreaker.annotation.CircuitBreaker;\n<span class=\"hljs-keyword\">import<\/span> io.github.resilience4j.retry.annotation.Retry;\n@RestController\npublic <span class=\"hljs-class\"><span class=\"hljs-keyword\">class<\/span> <span class=\"hljs-title\">FrontendController<\/span> <\/span>{\n\tprivate RestTemplate restTemplate;\n\t\n\tprivate <span class=\"hljs-keyword\">static<\/span> final Logger LOGGER = LoggerFactory.getLogger(FrontendController.class);\n\n\t@Value(<span class=\"hljs-string\">\"${backend.service.url}\"<\/span>)\n\tprivate <span class=\"hljs-built_in\">String<\/span> backendServiceUrl;\n\n\tpublic FrontendController(RestTemplate restTemplate) {\n\t\t<span class=\"hljs-keyword\">this<\/span>.restTemplate = restTemplate;\n\t}\n\t@GetMapping(<span class=\"hljs-string\">\"\/api\/circuit-breaker\"<\/span>)\n\t@CircuitBreaker(name = <span class=\"hljs-string\">\"demoCircuitBreaker\"<\/span>, fallbackMethod = <span class=\"hljs-string\">\"circuitBreakerFallback\"<\/span>)\n\tpublic <span class=\"hljs-built_in\">String<\/span> getCircuitBreakerResponse() {\n\t\t<span class=\"hljs-keyword\">return<\/span> getResponseFromBackend();\n\t}\n\t\n\t@GetMapping(<span class=\"hljs-string\">\"\/api\/retry\"<\/span>)\n   @Retry(name = <span class=\"hljs-string\">\"backendRetry\"<\/span>, fallbackMethod = <span class=\"hljs-string\">\"retryFallback\"<\/span>)\n   public <span class=\"hljs-built_in\">String<\/span> getRetryResponse() {\n\t\tLOGGER.info(<span class=\"hljs-string\">\"Trying call in thread: {}\"<\/span>, Thread.currentThread().getName());\n       <span class=\"hljs-keyword\">return<\/span> getResponseFromBackend();\n   }\n\t\n\t@GetMapping(<span class=\"hljs-string\">\"\/api\/bulkhead\"<\/span>)\n\t@Bulkhead(name = <span class=\"hljs-string\">\"demoBulkhead\"<\/span>, type = Bulkhead.Type.SEMAPHORE, fallbackMethod = <span class=\"hljs-string\">\"bulkheadFallback\"<\/span>)\n\tpublic <span class=\"hljs-built_in\">String<\/span> getResponse() {\n\t\t<span class=\"hljs-keyword\">try<\/span> {\n\t\t\tLOGGER.info(<span class=\"hljs-string\">\"Processing request in thread: \"<\/span>, Thread.currentThread().getName());\n\t        Thread.sleep(<span class=\"hljs-number\">5000<\/span>);\n\t    } <span class=\"hljs-keyword\">catch<\/span> (InterruptedException e) {\n\t        Thread.currentThread().interrupt();\n\t    }\n\t\t<span class=\"hljs-keyword\">return<\/span> getResponseFromBackend();\n\t}\n\tprivate <span class=\"hljs-built_in\">String<\/span> circuitBreakerFallback(Throwable throwable) {\n\t\tLOGGER.info(<span class=\"hljs-string\">\"Circuit breaker fallback triggered: \"<\/span>, throwable.getClass().getSimpleName());\n\t\t<span class=\"hljs-keyword\">return<\/span> <span class=\"hljs-string\">\"Fallback: Circuit breaker is open - \"<\/span> + throwable.getMessage();\n\t}\n\t\n\tprivate <span class=\"hljs-built_in\">String<\/span> retryFallback(Throwable throwable) {\n\t\tLOGGER.info(<span class=\"hljs-string\">\"Retry fallback triggered: \"<\/span>, throwable.getClass().getSimpleName());\n       <span class=\"hljs-keyword\">return<\/span> <span class=\"hljs-string\">\"Retry Fallback: Failed after retries - \"<\/span> + throwable.getMessage();\n   }\n\tprivate <span class=\"hljs-built_in\">String<\/span> bulkheadFallback(Throwable throwable) {\n\t\tLOGGER.info(<span class=\"hljs-string\">\"Bulkhead fallback triggered: \"<\/span>, throwable.getClass().getSimpleName());\n\t\t<span class=\"hljs-keyword\">return<\/span> <span class=\"hljs-string\">\"Bulkhead Fallback: Too many concurrent calls\"<\/span>;\n\t}\n\t\n\tprivate <span class=\"hljs-built_in\">String<\/span> getResponseFromBackend() {\n\t\t<span class=\"hljs-keyword\">return<\/span> restTemplate.getForObject(backendServiceUrl, <span class=\"hljs-built_in\">String<\/span>.class);\n\t}\n}<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-5\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h4 class=\"wp-block-heading\"><strong>What This Does:<\/strong><\/h4>\n\n\n\n<h6 class=\"wp-block-heading\" style=\"font-size:18px\"><strong>1. @CircuitBreaker(name = &#8220;demoCircuitBreaker&#8221;, fallbackMethod = &#8220;circuitBreakerFallback&#8221;)<\/strong>:<\/h6>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Protects against failing calls to the backend. If the backend fails repeatedly, it &#8220;opens&#8221; the circuit and returns a fallback response.&nbsp;<\/li>\n\n\n\n<li>Executes the fallback method circuitBreakerFallback when the circuitBreaker resilience is triggered<\/li>\n<\/ul>\n\n\n\n<h6 class=\"wp-block-heading\" style=\"font-size:18px\"><strong>2. @Retry(name = &#8220;backendRetry&#8221;, fallbackMethod = &#8220;retryFallback&#8221;)<\/strong>:<\/h6>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Retries failed backend calls a configurable number of times before ultimately failing and returning a fallback response.<\/li>\n\n\n\n<li>Executes the fallback method retryFallback when the retry resilience is triggered.<\/li>\n<\/ul>\n\n\n\n<h6 class=\"wp-block-heading\" style=\"font-size:18px\"><strong>3. @Bulkhead(name = &#8220;demoBulkhead&#8221;, type = Bulkhead.Type.THREADPOOL, fallbackMethod = &#8220;bulkheadFallback&#8221;)<\/strong>:<\/h6>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Limits the number of concurrent calls to the backend. If the limit is reached, the request is queued or rejected.<\/li>\n\n\n\n<li>Executes the fallback method bulkheadFallback when the bulkhead resilience is triggered<\/li>\n<\/ul>\n\n\n\n<p>Also, we need to define the RestTemplate bean in the application class.<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-6\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript\">@SpringBootApplication\n@EnableAspectJAutoProxy\npublic <span class=\"hljs-class\"><span class=\"hljs-keyword\">class<\/span> <span class=\"hljs-title\">FrontendApplication<\/span> <\/span>{\n\tpublic <span class=\"hljs-keyword\">static<\/span> <span class=\"hljs-keyword\">void<\/span> main(<span class=\"hljs-built_in\">String<\/span>&#091;] args) {\n\t\tSpringApplication.run(FrontendApplication.class, args);\n\t}\n   @Bean\n   RestTemplate restTemplate() {\n\t\t<span class=\"hljs-keyword\">return<\/span> <span class=\"hljs-keyword\">new<\/span> RestTemplate();\n\t}\n}<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-6\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>The frontend application is now ready to run on port 8080.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Backend Application Setup :<\/strong><\/h3>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>Dependencies and configuration&nbsp;<\/strong><\/h4>\n\n\n\n<p>Now to build a simple Spring web application with an endpoint simulating different failure scenarios, we need to include the following dependencies. If you&#8217;re also planning to implement asynchronous communication, integrating<a href=\"https:\/\/mobisoftinfotech.com\/resources\/blog\/devops\/spring-boot-apache-kafka-guide?utm_source=blog&amp;utm_campaign=resilience4j-circuit-breaker-retry-bulkhead-spring-boot\"> Spring Boot with Apache Kafka<\/a> can enhance fault isolation and event-driven resilience.<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-7\" data-shcb-language-name=\"HTML, XML\" data-shcb-language-slug=\"xml\"><span><code class=\"hljs language-xml\"><span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">dependency<\/span>&gt;<\/span>\n \t<span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">groupId<\/span>&gt;<\/span>org.springframework.boot<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">groupId<\/span>&gt;<\/span>\n \t<span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">artifactId<\/span>&gt;<\/span>spring-boot-starter-web<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">artifactId<\/span>&gt;<\/span>\n<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">dependency<\/span>&gt;<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-7\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">HTML, XML<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">xml<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>For application.properties, need basic configuration as below.<\/p>\n\n\n<pre class=\"wp-block-code\"><span><code class=\"hljs\">spring.application.name=backend\nserver.port=8081<\/code><\/span><\/pre>\n\n\n<p>If you have application.yml<\/p>\n\n\n<pre class=\"wp-block-code\"><span><code class=\"hljs\">spring:\n application:\n   name: backend\n\nserver:\n port: 8081\n<\/code><\/span><\/pre>\n\n\n<h4 class=\"wp-block-heading\"><strong>Simulating failures in the backend service<\/strong><\/h4>\n\n\n\n<p>Create a <code>BackendController<\/code> class to handle incoming requests from the frontend service with an endpoint that generates random failures.<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-8\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript\"><span class=\"hljs-keyword\">import<\/span> java.util.Random;\n<span class=\"hljs-keyword\">import<\/span> org.springframework.web.bind.annotation.GetMapping;\n<span class=\"hljs-keyword\">import<\/span> org.springframework.web.bind.annotation.RequestMapping;\n<span class=\"hljs-keyword\">import<\/span> org.springframework.web.bind.annotation.RestController;\n@RequestMapping(<span class=\"hljs-string\">\"\/data\"<\/span>)\n@RestController\npublic <span class=\"hljs-class\"><span class=\"hljs-keyword\">class<\/span> <span class=\"hljs-title\">BackendController<\/span> <\/span>{\n\t\n\tprivate final Random random = <span class=\"hljs-keyword\">new<\/span> Random();\n\t\n\t@GetMapping\n\tpublic <span class=\"hljs-built_in\">String<\/span> getData() {\n\t\t<span class=\"hljs-keyword\">if<\/span> (random.nextBoolean()) {\n           <span class=\"hljs-keyword\">throw<\/span> <span class=\"hljs-keyword\">new<\/span> RuntimeException(<span class=\"hljs-string\">\"Simulated backend failure\"<\/span>);\n       }\n\t\t<span class=\"hljs-keyword\">return<\/span> <span class=\"hljs-string\">\"Backend: Success!\"<\/span>;\n\t}\n}<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-8\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>The backend application is now ready to run on port 8081.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Testing Resilience Patterns<\/strong><\/h2>\n\n\n\n<p>In order to check the resilience patterns in action, run both applications on defined ports and try accessing the frontend APIs.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Testing the scenarios:<\/strong><\/h3>\n\n\n\n<p>Once both frontend (port <code>8080<\/code>) and backend (port <code>8081<\/code>) services are running, use the approaches below to simulate failures and observe how each Resilience4j pattern behaves.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>1.&nbsp; Circuit Breaker<\/strong><\/h4>\n\n\n\n<p><strong>Endpoint<\/strong>: <code>http:\/\/localhost:8080\/api\/circuit-breaker<\/code><\/p>\n\n\n\n<p><strong>Test Objective:<\/strong> Simulate repeated backend failures to trip the circuit breaker.<\/p>\n\n\n\n<h5 class=\"wp-block-heading\"><strong>Steps:<\/strong><\/h5>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Call the endpoint multiple times (5 times if <code>slidingWindowSize=5<\/code>).<\/li>\n\n\n\n<li>Ensure the backend returns failure for at least <code>50%<\/code> of calls (<code>failureRateThreshold=50<\/code>).<\/li>\n\n\n\n<li>Observe that after reaching the threshold, calls immediately return the fallback response:<br><em>&#8220;Fallback: Circuit breaker is open &#8211; 500 on GET request for &#8220;http:\/\/localhost:8081\/data&#8221;<\/em><\/li>\n<\/ul>\n\n\n\n<h5 class=\"wp-block-heading\"><strong>Verify Logs:<\/strong><\/h5>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Fallback method gets triggered, logs are visible in the terminal.<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-full\"><noscript><img decoding=\"async\" width=\"855\" height=\"98\" src=\"https:\/\/mobisoftinfotech.com\/resources\/wp-content\/uploads\/2025\/06\/resilience4j-fallback-method-logs.png\" alt=\"resilience4j fallback method logs in circuit breaker\" class=\"wp-image-39608\" title=\"Circuit Breaker Fallback Trigger\"><\/noscript><img decoding=\"async\" width=\"855\" height=\"98\" src=\"data:image\/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%20855%2098%22%3E%3C%2Fsvg%3E\" alt=\"resilience4j fallback method logs in circuit breaker\" class=\"wp-image-39608 lazyload\" title=\"Circuit Breaker Fallback Trigger\" data-src=\"https:\/\/mobisoftinfotech.com\/resources\/wp-content\/uploads\/2025\/06\/resilience4j-fallback-method-logs.png\"><\/figure>\n\n\n\n<h5 class=\"wp-block-heading\"><strong>Curl test loop:<\/strong><\/h5>\n\n\n\n<p><code>for i in {1..10}; do curl http:\/\/localhost:8080\/api\/circuit-breaker; sleep 1; done<\/code><\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><noscript><img decoding=\"async\" width=\"855\" height=\"98\" src=\"https:\/\/mobisoftinfotech.com\/resources\/wp-content\/uploads\/2025\/06\/curl-test-circuit-breaker.png\" alt=\"resilience4j fallback method logs in circuit breaker\" class=\"wp-image-39611\" title=\"Curl Loop Testing Circuit Breaker\"><\/noscript><img decoding=\"async\" width=\"855\" height=\"98\" src=\"data:image\/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%20855%2098%22%3E%3C%2Fsvg%3E\" alt=\"resilience4j fallback method logs in circuit breaker\" class=\"wp-image-39611 lazyload\" title=\"Curl Loop Testing Circuit Breaker\" data-src=\"https:\/\/mobisoftinfotech.com\/resources\/wp-content\/uploads\/2025\/06\/curl-test-circuit-breaker.png\"><\/figure>\n\n\n\n<p>For more formatted output in the terminal using curl &#8211;<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-9\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\"><span class=\"hljs-keyword\">for<\/span> i in {<span class=\"hljs-number\">1.<\/span><span class=\"hljs-number\">.10<\/span>}; <span class=\"hljs-keyword\">do<\/span>\n  <span class=\"hljs-keyword\">echo<\/span> <span class=\"hljs-string\">\"Request #$i - $(date '+%Y-%m-%d %H:%M:%S')\"<\/span>\n  curl -s http:<span class=\"hljs-comment\">\/\/localhost:8080\/api\/circuit-breaker<\/span>\n  <span class=\"hljs-keyword\">echo<\/span> -e <span class=\"hljs-string\">\"\\n-----------------------------\"<\/span>\n  sleep <span class=\"hljs-number\">1<\/span>\ndone<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-9\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<figure class=\"wp-block-image size-full\"><noscript><img decoding=\"async\" width=\"855\" height=\"312\" src=\"https:\/\/mobisoftinfotech.com\/resources\/wp-content\/uploads\/2025\/06\/curl-output-resilience4j.png\" alt=\"output in terminal for resilience4j circuit breaker\" class=\"wp-image-39612\" title=\"Curl Output: Circuit Breaker Call\"><\/noscript><img decoding=\"async\" width=\"855\" height=\"312\" src=\"data:image\/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%20855%20312%22%3E%3C%2Fsvg%3E\" alt=\"output in terminal for resilience4j circuit breaker\" class=\"wp-image-39612 lazyload\" title=\"Curl Output: Circuit Breaker Call\" data-src=\"https:\/\/mobisoftinfotech.com\/resources\/wp-content\/uploads\/2025\/06\/curl-output-resilience4j.png\"><\/figure>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>2. Retry<\/strong><\/h4>\n\n\n\n<p><strong>Endpoint: <\/strong><code>http:\/\/localhost:8080\/api\/retry<\/code><\/p>\n\n\n\n<p><strong>Test Objective: <\/strong>Confirm that failed calls are retried automatically.<\/p>\n\n\n\n<h5 class=\"wp-block-heading\"><strong>Steps:<\/strong><\/h5>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Call the endpoint.<\/li>\n\n\n\n<li>If the backend randomly fails, the frontend will retry up to 3 times (<code>maxAttempts=3<\/code>).<\/li>\n\n\n\n<li>After 3 failures, fallback is triggered with response:<br><em>&#8220;Retry Fallback: Failed after retries&#8221;<\/em><\/li>\n\n\n\n<li>If unable to trigger the fallback, you can try stopping the backend service running on port 8081 and API call attempts can be seen in the logs as per max attempts configured, 3 in this case.&nbsp;<\/li>\n<\/ul>\n\n\n\n<p><em>\u201cTrying call in thread: http-nio-8080-exec-1\u201d<\/em><\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><noscript><img decoding=\"async\" width=\"855\" height=\"112\" src=\"https:\/\/mobisoftinfotech.com\/resources\/wp-content\/uploads\/2025\/06\/resilience4j-retry-in-thread.png\" alt=\"retry pattern in microservices with resilience4j\" class=\"wp-image-39613\" title=\"Retry Pattern Call in Thread\"><\/noscript><img decoding=\"async\" width=\"855\" height=\"112\" src=\"data:image\/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%20855%20112%22%3E%3C%2Fsvg%3E\" alt=\"retry pattern in microservices with resilience4j\" class=\"wp-image-39613 lazyload\" title=\"Retry Pattern Call in Thread\" data-src=\"https:\/\/mobisoftinfotech.com\/resources\/wp-content\/uploads\/2025\/06\/resilience4j-retry-in-thread.png\"><\/figure>\n\n\n\n<h5 class=\"wp-block-heading\"><strong>Verify Logs:<\/strong><\/h5>\n\n\n\n<ul class=\"wp-block-list\">\n<li>API calls are logged<\/li>\n\n\n\n<li>The fallback method is only called after all retries are exhausted.<\/li>\n<\/ul>\n\n\n\n<h5 class=\"wp-block-heading\"><strong>Curl test:<\/strong><\/h5>\n\n\n\n<p><code>curl http:\/\/localhost:8080\/api\/retry<\/code><\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><noscript><img decoding=\"async\" width=\"855\" height=\"83\" src=\"https:\/\/mobisoftinfotech.com\/resources\/wp-content\/uploads\/2025\/06\/curl-test-retry-pattern.png\" alt=\"retry pattern tested in spring boot with curl\" class=\"wp-image-39614\" title=\"Curl Testing Retry Pattern\"><\/noscript><img decoding=\"async\" width=\"855\" height=\"83\" src=\"data:image\/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%20855%2083%22%3E%3C%2Fsvg%3E\" alt=\"retry pattern tested in spring boot with curl\" class=\"wp-image-39614 lazyload\" title=\"Curl Testing Retry Pattern\" data-src=\"https:\/\/mobisoftinfotech.com\/resources\/wp-content\/uploads\/2025\/06\/curl-test-retry-pattern.png\"><\/figure>\n\n\n\n<p>Run multiple times to observe retry and fallback behavior on failure.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>3.&nbsp; Bulkhead<\/strong><\/h4>\n\n\n\n<p><strong>Endpoint: <\/strong><code>http:\/\/localhost:8080\/api\/bulkhead<\/code><\/p>\n\n\n\n<p><strong>Test Objective: <\/strong>Simulate concurrent load to trigger bulkhead limits.<\/p>\n\n\n\n<h5 class=\"wp-block-heading\">Steps:<\/h5>\n\n\n\n<ul class=\"wp-block-list\">\n<li>The frontend API sleeps for <code>5 seconds<\/code> before responding.<\/li>\n\n\n\n<li>Bulkhead allows only 3 concurrent calls (<code>maxConcurrentCalls=3<\/code>).<\/li>\n\n\n\n<li>Fire 10 parallel requests to simulate load.<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">Expected Behavior:<\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li>The first 3 requests are processed.<\/li>\n\n\n\n<li>Remaining calls are rejected immediately if <code>maxWaitDuration=0<\/code>.<\/li>\n\n\n\n<li>Rejected requests will return:<br><em>&#8220;Bulkhead fallback triggered: BulkheadFullException&#8221;<\/em><\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-full\"><noscript><img decoding=\"async\" width=\"855\" height=\"178\" src=\"https:\/\/mobisoftinfotech.com\/resources\/wp-content\/uploads\/2025\/06\/bulkhead-pattern-fallback-example.png\" alt=\"bulkhead pattern in microservices with fallback logic\" class=\"wp-image-39615\" title=\"Bulkhead Pattern Fallback\"><\/noscript><img decoding=\"async\" width=\"855\" height=\"178\" src=\"data:image\/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%20855%20178%22%3E%3C%2Fsvg%3E\" alt=\"bulkhead pattern in microservices with fallback logic\" class=\"wp-image-39615 lazyload\" title=\"Bulkhead Pattern Fallback\" data-src=\"https:\/\/mobisoftinfotech.com\/resources\/wp-content\/uploads\/2025\/06\/bulkhead-pattern-fallback-example.png\"><\/figure>\n\n\n\n<h5 class=\"wp-block-heading\"><strong>Curl load test:<\/strong><\/h5>\n\n\n\n<p><code>for i in {1..10}; do curl http:\/\/localhost:8080\/api\/bulkhead &amp; done; wait<\/code><\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><noscript><img decoding=\"async\" width=\"855\" height=\"216\" src=\"https:\/\/mobisoftinfotech.com\/resources\/wp-content\/uploads\/2025\/06\/retry-pattern-load-test.png\" alt=\"resilience4j retry mechanism tested under load\" class=\"wp-image-39616\" title=\"Retry Load Test Using Curl\"><\/noscript><img decoding=\"async\" width=\"855\" height=\"216\" src=\"data:image\/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%20855%20216%22%3E%3C%2Fsvg%3E\" alt=\"resilience4j retry mechanism tested under load\" class=\"wp-image-39616 lazyload\" title=\"Retry Load Test Using Curl\" data-src=\"https:\/\/mobisoftinfotech.com\/resources\/wp-content\/uploads\/2025\/06\/retry-pattern-load-test.png\"><\/figure>\n\n\n\n<h4 class=\"wp-block-heading\">Verify Logs:<\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Log should show &#8220;Bulkhead fallback triggered&#8221; for rejected requests.<br><\/li>\n\n\n\n<li>The backend should only receive up to 3 requests at once.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Recap of Resilience Patterns Used<\/strong><\/h3>\n\n\n\n<p>In a microservices architecture, resilience patterns in Java help mitigate risks from downstream failures. Below are the three core Resilience4j patterns used in this tutorial:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Circuit Breaker: <\/strong>Prevents repeated calls to a failing backend by &#8220;opening&#8221; the circuit after a failure threshold is reached, allowing the system to recover without additional load.<\/li>\n\n\n\n<li><strong>Retry<\/strong>: Automatically re-attempts failed backend calls a configured number of times, helping recover from transient issues like network blips or temporary service unavailability.<\/li>\n\n\n\n<li><strong>Bulkhead<\/strong>: Limits the number of concurrent backend calls to prevent resource exhaustion and contain failures within specific service boundaries.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Real-World Benefits of These Patterns<\/strong><\/h3>\n\n\n\n<p>These microservices resilience patterns don\u2019t just sound good in theory; \u2014 they translate into practical, operational benefits:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>System Stability: <\/strong>Prevents one failing component from cascading into widespread failure across services.<\/li>\n\n\n\n<li><strong>Better Resource Utilization: <\/strong>Bulkhead, Circuit Breaker, and Retry help optimize thread usage and reduce unnecessary strain on downstream services.<\/li>\n\n\n\n<li><strong>Improved User Experience: <\/strong>Users see graceful fallbacks instead of raw exceptions or long timeouts, leading to a more resilient front-end experience.<\/li>\n\n\n\n<li><strong>Self-Healing Capabilities:<\/strong> Retry allows services to recover from temporary failures without requiring manual intervention.<\/li>\n\n\n\n<li><strong>Operational Visibility: <\/strong>With built-in metrics and Spring Boot Actuator integration, these patterns offer valuable insight into service health and performance.<\/li>\n\n\n\n<li><strong>Scalability<\/strong>: These resilience techniques help microservices remain robust under high load, improving fault isolation and supporting dynamic scaling in production.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>E-commerce Microservices in Action with Resilience4j<\/strong><\/h2>\n\n\n\n<figure class=\"wp-block-image size-full\"><noscript><img decoding=\"async\" width=\"1200\" height=\"587\" src=\"https:\/\/mobisoftinfotech.com\/resources\/wp-content\/uploads\/2025\/06\/ecommerce-resilience4j-use-case.png\" alt=\"resilience patterns in e-commerce microservices\" class=\"wp-image-39609\" title=\"E-commerce Microservices with Resilience\"><\/noscript><img decoding=\"async\" width=\"1200\" height=\"587\" src=\"data:image\/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%201200%20587%22%3E%3C%2Fsvg%3E\" alt=\"resilience patterns in e-commerce microservices\" class=\"wp-image-39609 lazyload\" title=\"E-commerce Microservices with Resilience\" data-src=\"https:\/\/mobisoftinfotech.com\/resources\/wp-content\/uploads\/2025\/06\/ecommerce-resilience4j-use-case.png\"><\/figure>\n\n\n\n<p>Above is a simple diagram of an E-commerce application with different services like products, orders, and carts. These services work together to handle user interactions such as browsing products, managing the shopping cart, and placing orders. To make the system more resilient and user-friendly, we apply different Resilience4j patterns. Let\u2019s look at three of them in the context of this application:<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Product Service \u2013 Circuit Breaker<\/strong><\/h3>\n\n\n\n<p>Your Product Service is down due to a database outage. If your Frontend Service keeps trying to call it, every request takes time to fail, and wastes system resources.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>With Circuit Breaker:<\/strong><\/h4>\n\n\n\n<p>After a threshold of failures, the circuit opens. All future calls are blocked immediately (and optionally routed to a fallback), avoiding further strain and speeding up failure responses.<\/p>\n\n\n\n<p><strong>Example fallback response:<\/strong> \u201cProducts are temporarily unavailable. Showing top-rated items from cache.\u201d<\/p>\n\n\n\n<p><strong>Benefit<\/strong>: Prevents cascading failures and keeps the user experience responsive even when services are down.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Order Service \u2013 Retry<\/strong><\/h3>\n\n\n\n<p>Sometimes, placing an order fails due to a temporary network glitch or a short-lived backend issue. If the request is not retried, the order fails even though the service may recover in a second.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>With Retry:<\/strong><\/h4>\n\n\n\n<p>The system automatically re-invokes the failed call a defined number of times with optional delays. If the issue is transient, the retry succeeds and the order is placed without the user noticing any problem.<\/p>\n\n\n\n<p><strong>Benefit<\/strong>: Helps recover from momentary errors and improves the overall success rate of operations.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Cart Service \u2013 Bulkhead<\/strong><\/h3>\n\n\n\n<p>Let\u2019s say the Cart Service becomes slow due to a spike in user activity or a backend bottleneck. Without proper isolation, it can consume too many threads and degrade the performance of the entire system.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>With Bulkhead:<\/strong><\/h4>\n\n\n\n<p>Each service is allocated a fixed number of threads or resources. If the Cart Service gets overloaded, only its share of resources is affected; other services like Products and Orders remain unaffected and continue working smoothly.<\/p>\n\n\n\n<p><strong>Benefit<\/strong>: Limits the blast radius of failures and ensures system stability under load.<\/p>\n\n\n\n<p>These Resilience4j patterns help ensure that even when something goes wrong in one part of the system, the rest of the application continues to function reliably, delivering a smoother experience for your customers.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Conclusion<\/strong><\/h2>\n\n\n\n<p>In this comprehensive tutorial, we demonstrated how to apply Resilience4j Circuit Breaker, Retry, and Bulkhead patterns within a <a href=\"https:\/\/mobisoftinfotech.com\/resources\/blog\/essential-principles-spring-boot-microservices\">Spring Boot microservices<\/a> architecture. Using a frontend-backend simulation, we introduced real failure scenarios and implemented robust resilience mechanisms to handle them.<\/p>\n\n\n\n<p>Building resilient microservices is no longer optional; it&#8217;s a necessity in modern distributed systems where partial failures, latency spikes, and overloaded services are everyday realities. Patterns like Circuit Breaker, Retry, and Bulkhead provide time-tested strategies to handle these issues gracefully, and Resilience4j brings these patterns to your Java applications in a lightweight, modular, and easy-to-integrate form.<\/p>\n\n\n\n<p>For teams building<a href=\"https:\/\/mobisoftinfotech.com\/services\/cloud-development?utm_source=blog&amp;utm_campaign=resilience4j-circuit-breaker-retry-bulkhead-spring-boot\"> cloud-native microservices<\/a>, Resilience4j simplifies the integration of failure handling mechanisms without adding complexity.<\/p>\n\n\n\n<p>By proactively designing your microservices to handle failure scenarios, you improve system availability, protect critical resources, and deliver a better user experience even under duress.<\/p>\n\n\n\n<p>If you&#8217;re building microservices with Java or Spring Boot, adopting Resilience4j is a smart step toward making your services more robust, self-healing, and production-ready. It&#8217;s easy to configure, well-documented, and aligns perfectly with modern resilience engineering practices.<\/p>\n\n\n\n<p>Start small, maybe with a Circuit Breaker on one critical dependency, and evolve your resilience strategy as your system grows.<\/p>\n\n\n\n<p>For teams building cloud-native microservices, Resilience4j simplifies the integration of failure handling mechanisms without adding complexity. You can explore the complete source code and implementation details on our official<a href=\"https:\/\/github.com\/mobisoftinfotech\/circuit-breaker-with-resilience4j-tutorial\" target=\"_blank\" rel=\"noreferrer noopener\"> GitHub<\/a> repository. <a href=\"https:\/\/resilience4j.readme.io\/\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">Official Resilience4j Documentation<\/a> to explore in detail more configuration options for all resilience patterns.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/mobisoftinfotech.com\/contact-us?utm_source=blog_cta&amp;utm_campaign=resilience4j-circuit-breaker-retry-bulkhead-spring-boot\"><noscript><img decoding=\"async\" width=\"855\" height=\"363\" src=\"https:\/\/mobisoftinfotech.com\/resources\/wp-content\/uploads\/2025\/06\/build-resilient-digital-products.png\" alt=\"Build your next big idea with resilient architecture\" class=\"wp-image-39610\" title=\"Technology Consulting CTA\"><\/noscript><img decoding=\"async\" width=\"855\" height=\"363\" src=\"data:image\/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%20855%20363%22%3E%3C%2Fsvg%3E\" alt=\"Build your next big idea with resilient architecture\" class=\"wp-image-39610 lazyload\" title=\"Technology Consulting CTA\" data-src=\"https:\/\/mobisoftinfotech.com\/resources\/wp-content\/uploads\/2025\/06\/build-resilient-digital-products.png\"><\/a><\/figure>\n\n\n<div class=\"modern-author-card\">\n    <div class=\"author-card-content\">\n        <div class=\"author-info-section\">\n            <div class=\"author-avatar\">\n                <noscript><img decoding=\"async\" src=\"https:\/\/mobisoftinfotech.com\/resources\/wp-content\/uploads\/2025\/06\/author-dattatray-dhawale.jpg\" alt=\"Dattatraya Dhawale\"><\/noscript><img decoding=\"async\" src=\"data:image\/gif;base64,R0lGODlhAQABAIAAAAAAAP\/\/\/yH5BAEAAAAALAAAAAABAAEAAAIBRAA7\" alt=\"Dattatraya Dhawale\" data-src=\"https:\/\/mobisoftinfotech.com\/resources\/wp-content\/uploads\/2025\/06\/author-dattatray-dhawale.jpg\" class=\" lazyload\">\n            <\/div>\n            <div class=\"author-details\">\n                <h3 class=\"author-name\">Dattatraya Dhawale<\/h3>\n                <p class=\"author-title\">Java Developer<\/p>\n                <a href=\"javascript:void(0);\" class=\"read-more-link read-more-btn\" onclick=\"toggleAuthorBio(this); return false;\">Read more <noscript><img decoding=\"async\" src=\"\/assets\/images\/blog\/Vector.png\" alt=\"expand\" class=\"read-more-arrow down-arrow\"><\/noscript><img decoding=\"async\" src=\"data:image\/gif;base64,R0lGODlhAQABAIAAAAAAAP\/\/\/yH5BAEAAAAALAAAAAABAAEAAAIBRAA7\" alt=\"expand\" class=\"read-more-arrow down-arrow lazyload\" data-src=\"\/assets\/images\/blog\/Vector.png\"><\/a>\n                <div class=\"author-bio-expanded\">\n                    <p>Dattatraya Dhawale brings over 8 years of industry experience as a Java developer, focused on enterprise-grade backend development. At <a href=\"https:\/\/mobisoftinfotech.com?utm_source=blog&amp;utm_medium=internal_link&amp;utm_campaign=resilience4j-circuit-breaker_blog&amp;utm_content=home-page\">Mobisoft Infotech<\/a>, he builds robust, high-performing applications with a strong emphasis on scalability and seamless connectivity to third-party services. Driven by a pragmatic mindset and hands-on approach, Dattatraya also brings prior experience in Android development, adding versatility to his backend expertise.<\/p>\n                    <div class=\"author-social-links\"><div class=\"social-icon\"><a href=\"https:\/\/www.linkedin.com\/in\/dattatraya-dhawale-493689142\" target=\"_blank\" rel=\"nofollow noopener\"><i class=\"icon-sprite linkedin\"><\/i><\/a><\/div><\/div>\n                    <a href=\"javascript:void(0);\" class=\"read-more-link read-less-btn\" onclick=\"toggleAuthorBio(this); return false;\" style=\"display: none;\">Read less <noscript><img decoding=\"async\" src=\"\/assets\/images\/blog\/Vector.png\" alt=\"collapse\" class=\"read-more-arrow up-arrow\"><\/noscript><img decoding=\"async\" src=\"data:image\/gif;base64,R0lGODlhAQABAIAAAAAAAP\/\/\/yH5BAEAAAAALAAAAAABAAEAAAIBRAA7\" alt=\"collapse\" class=\"read-more-arrow up-arrow lazyload\" data-src=\"\/assets\/images\/blog\/Vector.png\"><\/a>\n                <\/div>\n            <\/div>\n        <\/div>\n        <div class=\"share-section\">\n            <span class=\"share-label\">Share Article<\/span>\n            <div class=\"social-share-buttons\">\n                <a href=\"https:\/\/www.facebook.com\/sharer\/sharer.php?u=https%3A%2F%2Fmobisoftinfotech.com%2Fresources%2Fblog%2Fmicroservices%2Fresilience4j-circuit-breaker-retry-bulkhead-spring-boot\" target=\"_blank\" class=\"share-btn facebook-share\"><i class=\"fa fa-facebook-f\"><\/i><\/a>\n                <a href=\"https:\/\/www.linkedin.com\/sharing\/share-offsite\/?url=https%3A%2F%2Fmobisoftinfotech.com%2Fresources%2Fblog%2Fmicroservices%2Fresilience4j-circuit-breaker-retry-bulkhead-spring-boot\" target=\"_blank\" class=\"share-btn linkedin-share\"><i class=\"fa fa-linkedin\"><\/i><\/a>\n            <\/div>\n        <\/div>\n    <\/div>\n<\/div>\n\n\n\n<style>\n.post-details-title{font-size:42px}\nh6.wp-block-heading {\n    line-height: 2;\n}\n\n.post-content p{\n    margin: 20px 0 20px;\n}\n\n\nh5.wp-block-heading{\nfont-size:20px;\n}\nh4.wp-block-heading{\nfont-size:20px;\n}\nh3.wp-block-heading{\nfont-size:22px;\n}\nh3.wp-block-heading.h3-list {\n    position: relative;\nfont-size:20px;\n    padding-left: 20px;\n}\n\nh3.wp-block-heading.h3-list:before {\n    position: absolute;\n    content: '';\n    background: #0d265c;\n    height: 9px;\n    width: 9px;\n    left: 0;\n    border-radius: 50px;\n    top: 8px;\n}\n@media only screen and (max-width: 991px) {\nul.wp-block-list.step-9-ul {\n    margin-left: 0px;\n}\n.step-9-h4{padding-left:0px;}\n    .post-content li {\n       padding-left: 25px;\n    }\n    .post-content li:before {\n        content: '';\n         width: 9px;\n        height: 9px;\n        background-color: #0d265c;\n        border-radius: 50%;\n        position: absolute;\n        left: 0px;\n        top: 12px;\n    }\n}\n<\/style>\n<script type=\"application\/ld+json\">\n    [\n    {\n            \"@context\": \"https:\/\/schema.org\",\n            \"@type\": \"ImageObject\",\n            \"contentUrl\": \"https:\/\/mobisoftinfotech.com\/resources\/wp-content\/uploads\/2025\/06\/custom-software-development-solutions.png\",\n            \"url\": \"https:\/\/mobisoftinfotech.com\/resources\/blog\/microservices\/resilience4j-circuit-breaker-retry-bulkhead-spring-boot\",\n            \"name\": \" Custom Software Development CTA\",\n            \"caption\": \"Tailored software solutions for microservices resilience\",\n            \"description\": \"Promote how unique microservices architectures require customized software development approaches for resilience and performance.\",\n            \"license\": \"https:\/\/mobisoftinfotech.com\/terms\",\n            \"acquireLicensePage\": \"https:\/\/mobisoftinfotech.com\/acquire-license\",\n            \"creditText\": \"Mobisoft Infotech\",\n            \"copyrightNotice\": \"Mobisoft Infotech\",\n            \"creator\": {\n                \"@type\": \"Organization\",\n                \"name\": \"Mobisoft Infotech\"\n            },\n            \"thumbnail\": \"https:\/\/mobisoftinfotech.com\/resources\/wp-content\/uploads\/2025\/06\/custom-software-development-solutions.png\"\n        },\n        {\n            \"@context\": \"https:\/\/schema.org\",\n            \"@type\": \"ImageObject\",\n            \"contentUrl\": \"https:\/\/mobisoftinfotech.com\/resources\/wp-content\/uploads\/2025\/06\/build-resilient-digital-products.png\",\n            \"url\": \"https:\/\/mobisoftinfotech.com\/resources\/blog\/microservices\/resilience4j-circuit-breaker-retry-bulkhead-spring-boot\",\n            \"name\": \"Technology Consulting CTA\",\n            \"caption\": \"Partner with us to implement microservices resilience patterns\",\n            \"description\": \"Highlight your capability to turn innovative concepts into robust, scalable microservices solutions using Resilience4j.\",\n            \"license\": \"https:\/\/mobisoftinfotech.com\/terms\",\n            \"acquireLicensePage\": \"https:\/\/mobisoftinfotech.com\/acquire-license\",\n            \"creditText\": \"Mobisoft Infotech\",\n            \"copyrightNotice\": \"Mobisoft Infotech\",\n            \"creator\": {\n                \"@type\": \"Organization\",\n                \"name\": \"Mobisoft Infotech\"\n            },\n            \"thumbnail\": \"https:\/\/mobisoftinfotech.com\/resources\/wp-content\/uploads\/2025\/06\/build-resilient-digital-products.png\"\n        },\n        {\n            \"@context\": \"https:\/\/schema.org\",\n            \"@type\": \"ImageObject\",\n            \"contentUrl\": \"https:\/\/mobisoftinfotech.com\/resources\/wp-content\/uploads\/2025\/06\/resilience4j-circuit-breaker-retry-bulkhead-spring-boot.png\",\n            \"url\": \"https:\/\/mobisoftinfotech.com\/resources\/blog\/microservices\/resilience4j-circuit-breaker-retry-bulkhead-spring-boot\",\n            \"name\": \"Resilience4j Circuit Breaker Tutorial along with Retry & Bulkhead patterns for Spring Boot Microservices\",\n            \"caption\": \"A visual intro to Resilience4j with Retry and Bulkhead patterns\",\n            \"description\": \"A hero banner introducing Resilience4j implementation in Spring Boot for microservices fault tolerance.\",\n            \"license\": \"https:\/\/mobisoftinfotech.com\/terms\",\n            \"acquireLicensePage\": \"https:\/\/mobisoftinfotech.com\/acquire-license\",\n            \"creditText\": \"Mobisoft Infotech\",\n            \"copyrightNotice\": \"Mobisoft Infotech\",\n            \"creator\": {\n                \"@type\": \"Organization\",\n                \"name\": \"Mobisoft Infotech\"\n            },\n            \"thumbnail\": \"https:\/\/mobisoftinfotech.com\/resources\/wp-content\/uploads\/2025\/06\/resilience4j-circuit-breaker-retry-bulkhead-spring-boot.png\"\n        },\n        {\n            \"@context\": \"https:\/\/schema.org\",\n            \"@type\": \"ImageObject\",\n            \"contentUrl\": \"https:\/\/mobisoftinfotech.com\/resources\/wp-content\/uploads\/2025\/06\/author-dattatray-dhawale.png\",\n            \"url\": \"https:\/\/mobisoftinfotech.com\/resources\/blog\/microservices\/resilience4j-circuit-breaker-retry-bulkhead-spring-boot\",\n            \"name\": \"Author: Dattatray Dhawale\",\n            \"caption\": \"Technical insights from Dattatray Dhawale\",\n            \"description\": \"Author photo and attribution for the blog\u2019s technical content focused on Java resilience patterns.\",\n            \"license\": \"https:\/\/mobisoftinfotech.com\/terms\",\n            \"acquireLicensePage\": \"https:\/\/mobisoftinfotech.com\/acquire-license\",\n            \"creditText\": \"Mobisoft Infotech\",\n            \"copyrightNotice\": \"Mobisoft Infotech\",\n            \"creator\": {\n                \"@type\": \"Organization\",\n                \"name\": \"Mobisoft Infotech\"\n            },\n            \"thumbnail\": \"https:\/\/mobisoftinfotech.com\/resources\/wp-content\/uploads\/2025\/06\/author-dattatray-dhawale.png\"\n        },\n        {\n            \"@context\": \"https:\/\/schema.org\",\n            \"@type\": \"ImageObject\",\n            \"contentUrl\": \"https:\/\/mobisoftinfotech.com\/resources\/wp-content\/uploads\/2025\/06\/circuit-breaker-state-machine.png\",\n            \"url\": \"https:\/\/mobisoftinfotech.com\/resources\/blog\/microservices\/resilience4j-circuit-breaker-retry-bulkhead-spring-boot\",\n            \"name\": \"Circuit Breaker State Transitions\",\n            \"caption\": \"Visualizing CLOSED, OPEN, and HALF-OPEN states\",\n            \"description\": \"Diagram showcasing the core states in the Resilience4j circuit breaker implementation for fault detection.\",\n            \"license\": \"https:\/\/mobisoftinfotech.com\/terms\",\n            \"acquireLicensePage\": \"https:\/\/mobisoftinfotech.com\/acquire-license\",\n            \"creditText\": \"Mobisoft Infotech\",\n            \"copyrightNotice\": \"Mobisoft Infotech\",\n            \"creator\": {\n                \"@type\": \"Organization\",\n                \"name\": \"Mobisoft Infotech\"\n            },\n            \"thumbnail\": \"https:\/\/mobisoftinfotech.com\/resources\/wp-content\/uploads\/2025\/06\/circuit-breaker-state-machine.png\"\n        },\n        {\n            \"@context\": \"https:\/\/schema.org\",\n            \"@type\": \"ImageObject\",\n            \"contentUrl\": \"https:\/\/mobisoftinfotech.com\/resources\/wp-content\/uploads\/2025\/06\/resilience4j-fallback-method-logs.png\",\n            \"url\": \"https:\/\/mobisoftinfotech.com\/resources\/blog\/microservices\/resilience4j-circuit-breaker-retry-bulkhead-spring-boot\",\n            \"name\": \"Circuit Breaker Fallback Trigger\",\n            \"caption\": \"Fallback method execution during service failure\",\n            \"description\": \"Console output showing fallback execution triggered by a circuit breaker event in a failed microservice call.\",\n            \"license\": \"https:\/\/mobisoftinfotech.com\/terms\",\n            \"acquireLicensePage\": \"https:\/\/mobisoftinfotech.com\/acquire-license\",\n            \"creditText\": \"Mobisoft Infotech\",\n            \"copyrightNotice\": \"Mobisoft Infotech\",\n            \"creator\": {\n                \"@type\": \"Organization\",\n                \"name\": \"Mobisoft Infotech\"\n            },\n            \"thumbnail\": \"https:\/\/mobisoftinfotech.com\/resources\/wp-content\/uploads\/2025\/06\/resilience4j-fallback-method-logs.png\"\n        },\n        {\n            \"@context\": \"https:\/\/schema.org\",\n            \"@type\": \"ImageObject\",\n            \"contentUrl\": \"https:\/\/mobisoftinfotech.com\/resources\/wp-content\/uploads\/2025\/06\/curl-test-circuit-breaker.png\",\n            \"url\": \"https:\/\/mobisoftinfotech.com\/resources\/blog\/microservices\/resilience4j-circuit-breaker-retry-bulkhead-spring-boot\",\n            \"name\": \"Curl Loop Testing Circuit Breaker\",\n            \"caption\": \"Simulating circuit breaker state transition using curl\",\n            \"description\": \"Practical curl test output that demonstrates circuit breaker threshold handling in microservices.\",\n            \"license\": \"https:\/\/mobisoftinfotech.com\/terms\",\n            \"acquireLicensePage\": \"https:\/\/mobisoftinfotech.com\/acquire-license\",\n            \"creditText\": \"Mobisoft Infotech\",\n            \"copyrightNotice\": \"Mobisoft Infotech\",\n            \"creator\": {\n                \"@type\": \"Organization\",\n                \"name\": \"Mobisoft Infotech\"\n            },\n            \"thumbnail\": \"https:\/\/mobisoftinfotech.com\/resources\/wp-content\/uploads\/2025\/06\/curl-test-circuit-breaker.png\"\n        },\n        {\n            \"@context\": \"https:\/\/schema.org\",\n            \"@type\": \"ImageObject\",\n            \"contentUrl\": \"https:\/\/mobisoftinfotech.com\/resources\/wp-content\/uploads\/2025\/06\/curl-output-resilience4j.png\",\n            \"url\": \"https:\/\/mobisoftinfotech.com\/resources\/blog\/microservices\/resilience4j-circuit-breaker-retry-bulkhead-spring-boot\",\n            \"name\": \"Curl Output: Circuit Breaker Call\",\n            \"caption\": \"Response log for microservices circuit breaker test\",\n            \"description\": \"Terminal output representing how Resilience4j handles failed and successful service calls.\",\n            \"license\": \"https:\/\/mobisoftinfotech.com\/terms\",\n            \"acquireLicensePage\": \"https:\/\/mobisoftinfotech.com\/acquire-license\",\n            \"creditText\": \"Mobisoft Infotech\",\n            \"copyrightNotice\": \"Mobisoft Infotech\",\n            \"creator\": {\n                \"@type\": \"Organization\",\n                \"name\": \"Mobisoft Infotech\"\n            },\n            \"thumbnail\": \"https:\/\/mobisoftinfotech.com\/resources\/wp-content\/uploads\/2025\/06\/curl-output-resilience4j.png\"\n        },\n        {\n            \"@context\": \"https:\/\/schema.org\",\n            \"@type\": \"ImageObject\",\n            \"contentUrl\": \"https:\/\/mobisoftinfotech.com\/resources\/wp-content\/uploads\/2025\/06\/resilience4j-retry-in-thread.png\",\n            \"url\": \"https:\/\/mobisoftinfotech.com\/resources\/blog\/microservices\/resilience4j-circuit-breaker-retry-bulkhead-spring-boot\",\n            \"name\": \"Retry Pattern Call in Thread\",\n            \"caption\": \"Thread-based retry logic using resilience4j retry mechanism\",\n            \"description\": \"Thread-level demonstration of retry behavior using Resilience4j in a Spring Boot microservice.\",\n            \"license\": \"https:\/\/mobisoftinfotech.com\/terms\",\n            \"acquireLicensePage\": \"https:\/\/mobisoftinfotech.com\/acquire-license\",\n            \"creditText\": \"Mobisoft Infotech\",\n            \"copyrightNotice\": \"Mobisoft Infotech\",\n            \"creator\": {\n                \"@type\": \"Organization\",\n                \"name\": \"Mobisoft Infotech\"\n            },\n            \"thumbnail\": \"https:\/\/mobisoftinfotech.com\/resources\/wp-content\/uploads\/2025\/06\/resilience4j-retry-in-thread.png\"\n        },\n        {\n            \"@context\": \"https:\/\/schema.org\",\n            \"@type\": \"ImageObject\",\n            \"contentUrl\": \"https:\/\/mobisoftinfotech.com\/resources\/wp-content\/uploads\/2025\/06\/curl-test-retry-pattern.png\",\n            \"url\": \"https:\/\/mobisoftinfotech.com\/resources\/blog\/microservices\/resilience4j-circuit-breaker-retry-bulkhead-spring-boot\",\n            \"name\": \"Curl Testing Retry Pattern\",\n            \"caption\": \"Testing resilience4j retry mechanism via API calls\",\n            \"description\": \"Terminal test to verify retry logic in Resilience4j after a simulated backend failure.\",\n            \"license\": \"https:\/\/mobisoftinfotech.com\/terms\",\n            \"acquireLicensePage\": \"https:\/\/mobisoftinfotech.com\/acquire-license\",\n            \"creditText\": \"Mobisoft Infotech\",\n            \"copyrightNotice\": \"Mobisoft Infotech\",\n            \"creator\": {\n                \"@type\": \"Organization\",\n                \"name\": \"Mobisoft Infotech\"\n            },\n            \"thumbnail\": \"https:\/\/mobisoftinfotech.com\/resources\/wp-content\/uploads\/2025\/06\/curl-test-retry-pattern.png\"\n        },\n        {\n            \"@context\": \"https:\/\/schema.org\",\n            \"@type\": \"ImageObject\",\n            \"contentUrl\": \"https:\/\/mobisoftinfotech.com\/resources\/wp-content\/uploads\/2025\/06\/bulkhead-pattern-fallback-example.png\",\n            \"url\": \"https:\/\/mobisoftinfotech.com\/resources\/blog\/microservices\/resilience4j-circuit-breaker-retry-bulkhead-spring-boot\",\n            \"name\": \"Bulkhead Pattern Fallback\",\n            \"caption\": \"Isolated thread pool triggered fallback\",\n            \"description\": \"Illustration of fallback triggered due to thread pool exhaustion in the Resilience4j bulkhead pattern.\",\n            \"license\": \"https:\/\/mobisoftinfotech.com\/terms\",\n            \"acquireLicensePage\": \"https:\/\/mobisoftinfotech.com\/acquire-license\",\n            \"creditText\": \"Mobisoft Infotech\",\n            \"copyrightNotice\": \"Mobisoft Infotech\",\n            \"creator\": {\n                \"@type\": \"Organization\",\n                \"name\": \"Mobisoft Infotech\"\n            },\n            \"thumbnail\": \"https:\/\/mobisoftinfotech.com\/resources\/wp-content\/uploads\/2025\/06\/bulkhead-pattern-fallback-example.png\"\n        },\n        {\n            \"@context\": \"https:\/\/schema.org\",\n            \"@type\": \"ImageObject\",\n            \"contentUrl\": \"https:\/\/mobisoftinfotech.com\/resources\/wp-content\/uploads\/2025\/06\/retry-pattern-load-test.png\",\n            \"url\": \"https:\/\/mobisoftinfotech.com\/resources\/blog\/microservices\/resilience4j-circuit-breaker-retry-bulkhead-spring-boot\",\n            \"name\": \"Retry Load Test Using Curl\",\n            \"caption\": \"Load testing retry pattern in spring boot microservices\",\n            \"description\": \"Performance testing curl script simulating load against retry-enabled microservices endpoint.\",\n            \"license\": \"https:\/\/mobisoftinfotech.com\/terms\",\n            \"acquireLicensePage\": \"https:\/\/mobisoftinfotech.com\/acquire-license\",\n            \"creditText\": \"Mobisoft Infotech\",\n            \"copyrightNotice\": \"Mobisoft Infotech\",\n            \"creator\": {\n                \"@type\": \"Organization\",\n                \"name\": \"Mobisoft Infotech\"\n            },\n            \"thumbnail\": \"https:\/\/mobisoftinfotech.com\/resources\/wp-content\/uploads\/2025\/06\/retry-pattern-load-test.png\"\n        },\n        {\n            \"@context\": \"https:\/\/schema.org\",\n            \"@type\": \"ImageObject\",\n            \"contentUrl\": \"https:\/\/mobisoftinfotech.com\/resources\/wp-content\/uploads\/2025\/06\/ecommerce-resilience4j-use-case.png\",\n            \"url\": \"https:\/\/mobisoftinfotech.com\/resources\/blog\/microservices\/resilience4j-circuit-breaker-retry-bulkhead-spring-boot\",\n            \"name\": \"E-commerce Microservices with Resilience\",\n            \"caption\": \"Applying resilience4j patterns in e-commerce architecture\",\n            \"description\": \"Use-case scenario showing how e-commerce systems benefit from retry, bulkhead, and circuit breaker patterns.\",\n            \"license\": \"https:\/\/mobisoftinfotech.com\/terms\",\n            \"acquireLicensePage\": \"https:\/\/mobisoftinfotech.com\/acquire-license\",\n            \"creditText\": \"Mobisoft Infotech\",\n            \"copyrightNotice\": \"Mobisoft Infotech\",\n            \"creator\": {\n                \"@type\": \"Organization\",\n                \"name\": \"Mobisoft Infotech\"\n            },\n            \"thumbnail\": \"https:\/\/mobisoftinfotech.com\/resources\/wp-content\/uploads\/2025\/06\/ecommerce-resilience4j-use-case.png\"\n        },\n        {\n            \"@context\": \"https:\/\/schema.org\",\n            \"@type\": \"ImageObject\",\n            \"contentUrl\": \"https:\/\/mobisoftinfotech.com\/resources\/wp-content\/uploads\/2025\/06\/visualizing-resilience4j-patterns.png\",\n            \"url\": \"https:\/\/mobisoftinfotech.com\/resources\/blog\/microservices\/resilience4j-circuit-breaker-retry-bulkhead-spring-boot\",\n            \"name\": \"Visualizing Resilience4j Patterns\",\n            \"caption\": \"Side-by-side comparison of resilience4j features in action\",\n            \"description\": \"Infographic comparing Circuit Breaker, Retry, and Bulkhead implementations with outputs and fallback behavior.\",\n            \"license\": \"https:\/\/mobisoftinfotech.com\/terms\",\n            \"acquireLicensePage\": \"https:\/\/mobisoftinfotech.com\/acquire-license\",\n            \"creditText\": \"Mobisoft Infotech\",\n            \"copyrightNotice\": \"Mobisoft Infotech\",\n            \"creator\": {\n                \"@type\": \"Organization\",\n                \"name\": \"Mobisoft Infotech\"\n            },\n            \"thumbnail\": \"https:\/\/mobisoftinfotech.com\/resources\/wp-content\/uploads\/2025\/06\/visualizing-resilience4j-patterns.png\"\n        }\n        ]\n    <\/script>\n<script type=\"application\/ld+json\">\n{\n    \"@context\": \"https:\/\/schema.org\",\n    \"@type\": \"LocalBusiness\",\n    \"name\": \"Mobisoft Infotech\",\n    \"url\": \"https:\/\/mobisoftinfotech.com\",\n    \"logo\": \"https:\/\/mobisoftinfotech.com\/assets\/images\/mshomepage\/MI_Logo-white.svg\",\n    \"description\": \"Mobisoft Infotech specializes in custom software development and digital solutions.\",\n    \"address\": {\n        \"@type\": \"PostalAddress\",\n        \"streetAddress\": \"5718 Westheimer Rd Suite 1000\",\n        \"addressLocality\": \"Houston\",\n        \"addressRegion\": \"TX\",\n        \"postalCode\": \"77057\",\n        \"addressCountry\": \"USA\"\n    },\n    \"contactPoint\": [{\n        \"@type\": \"ContactPoint\",\n        \"telephone\": \"+1-855-572-2777\",\n        \"contactType\": \"Customer Service\",\n        \"areaServed\": [\"USA\", \"Worldwide\"],\n        \"availableLanguage\": [\"English\"]\n    }],\n    \"sameAs\": [\n        \"https:\/\/www.facebook.com\/pages\/Mobisoft-Infotech\/131035500270720\",\n        \"https:\/\/x.com\/MobisoftInfo\",\n        \"https:\/\/www.linkedin.com\/company\/mobisoft-infotech\",\n        \"https:\/\/in.pinterest.com\/mobisoftinfotech\/\",\n        \"https:\/\/www.instagram.com\/mobisoftinfotech\/\",\n        \"https:\/\/github.com\/MobisoftInfotech\",\n        \"https:\/\/www.behance.net\/MobisoftInfotech\",\n        \"https:\/\/www.youtube.com\/@MobisoftinfotechHouston\"\n    ]\n}\n<\/script>\n<script type=\"application\/ld+json\">\n{\n  \"@context\": \"https:\/\/schema.org\",\n  \"@type\": \"Organization\",\n  \"name\": \"Mobisoft Infotech\",\n  \"url\": \"https:\/\/mobisoftinfotech.com\/\",\n  \"logo\": \"https:\/\/mobisoftinfotech.com\/assets\/images\/MI_Logo.svg\",\n  \"sameAs\": [\n    \"https:\/\/www.facebook.com\/pages\/Mobisoft-Infotech\/131035500270720\",\n    \"https:\/\/x.com\/MobisoftInfo\",\n    \"https:\/\/www.instagram.com\/mobisoftinfotech\/\",\n    \"https:\/\/www.youtube.com\/@MobisoftinfotechHouston\",\n    \"https:\/\/www.linkedin.com\/company\/mobisoft-infotech\",\n    \"https:\/\/in.pinterest.com\/mobisoftinfotech\/\",\n    \"https:\/\/github.com\/MobisoftInfotech\"\n  ],\n  \"contactPoint\": [\n    {\n      \"@type\": \"ContactPoint\",\n      \"telephone\": \"+1-855-572-2777\",\n      \"contactType\": \"Customer Service\",\n      \"areaServed\": \"US\",\n      \"availableLanguage\": [\"English\"]\n    },\n    {\n      \"@type\": \"ContactPoint\",\n      \"telephone\": \"+91-858-600-8627\",\n      \"contactType\": \"Customer Service\",\n      \"areaServed\": \"IN\",\n      \"availableLanguage\": [\"English\"]\n    }\n  ]\n}\n<\/script>\n<script type=\"application\/ld+json\">\n{\n  \"@context\": \"https:\/\/schema.org\",\n  \"@type\": \"Article\",\n  \"mainEntityOfPage\": {\n    \"@type\": \"WebPage\",\n    \"@id\": \"https:\/\/mobisoftinfotech.com\/resources\/blog\/microservices\/rresilience4j-circuit-breaker-retry-bulkhead-spring-boot\"\n  },\n  \"headline\": \"Resilience4j Circuit Breaker Tutorial along with Retry & Bulkhead patterns for Spring Boot Microservices\",\n  \"description\": \"Learn how to implement Resilience4j Circuit Breaker, Retry & Bulkhead patterns in Spring Boot microservices for resilient fault-tolerant applications.\",\n  \"image\": \"https:\/\/mobisoftinfotech.com\/resources\/wp-content\/uploads\/2025\/6\/rresilience4j-circuit-breaker-retry-bulkhead-spring-boot\",\n  \"author\": {\n    \"@type\": \"Person\",\n    \"name\": \"Dattatraya Dhawale\",\n    \"description\": \"Dattatraya Dhawale brings over 8 years of industry experience as a Java developer, focused on enterprise-grade backend development.At Mobisoft Infotech, he builds robust, high-performing applications with a strong emphasis on scalability and seamless connectivity to third-party services. Driven by a pragmatic mindset and hands-on approach, Dattatraya also brings prior experience in Android development, adding versatility to his backend expertise.\"\n  },\n  \"publisher\": {\n    \"@type\": \"Organization\",\n    \"name\": \"Mobisoft Infotech\",\n    \"logo\": {\n      \"@type\": \"ImageObject\",\n      \"url\": \"https:\/\/mobisoftinfotech.com\/assets\/images\/mshomepage\/MI_Logo-white.svg\",\n      \"width\": 600,\n      \"height\": 600\n    }\n  },\n  \"datePublished\": \"2025-06-13\",\n  \"dateModified\": \"2025-06-13\"\n}\n<\/script>\n","protected":false},"excerpt":{"rendered":"<p>Introduction Microservices architecture has become the go-to approach for building scalable, modular, and independently deployable systems. By breaking down a system into smaller, loosely coupled services, teams can innovate faster and scale components independently.&nbsp; However, while microservices offer clear architectural benefits, they also introduce complexity, particularly around communication between services. These systems depend heavily on [&hellip;]<\/p>\n","protected":false},"author":119,"featured_media":39597,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_s2mail":"","footnotes":""},"categories":[6125],"tags":[6167,6164,6172,6168,6175,6170,6173,6165,6171,6174,6163,6169,6166],"class_list":["post-39594","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-microservices","tag-bulkhead-pattern-in-microservices","tag-circuit-breaker-pattern-in-microservices","tag-circuit-breaker-resilience4j-90","tag-how-to-use-resilience4j","tag-microservices-resilience-20","tag-microservices-resilience-patterns","tag-resilience-in-microservices-150","tag-resilience-patterns-in-java","tag-resilience-patterns-in-microservices-30","tag-resilience4j-bulkhead-pattern","tag-resilience4j-circuit-breaker","tag-resilience4j-retry-mechanism","tag-retry-pattern-in-microservices"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.2 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Resilience4j Circuit Breaker, Retry &amp; Bulkhead Tutorial<\/title>\n<meta name=\"description\" content=\"Learn how to implement Resilience4j Circuit Breaker, Retry &amp; Bulkhead patterns in Spring Boot microservices for resilient fault-tolerant applications.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/mobisoftinfotech.com\/resources\/blog\/microservices\/resilience4j-circuit-breaker-retry-bulkhead-spring-boot\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Resilience4j Circuit Breaker, Retry &amp; Bulkhead Tutorial\" \/>\n<meta property=\"og:description\" content=\"Learn how to implement Resilience4j Circuit Breaker, Retry &amp; Bulkhead patterns in Spring Boot microservices for resilient fault-tolerant applications.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/mobisoftinfotech.com\/resources\/blog\/microservices\/resilience4j-circuit-breaker-retry-bulkhead-spring-boot\" \/>\n<meta property=\"og:site_name\" content=\"Mobisoft Infotech\" \/>\n<meta property=\"article:published_time\" content=\"2025-06-13T15:23:43+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-11-04T05:06:34+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/mobisoftinfotech.com\/resources\/wp-content\/uploads\/2025\/06\/og-Resilience4j-Circuit-Breaker-Tutorial.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1000\" \/>\n\t<meta property=\"og:image:height\" content=\"525\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Dattatray Dhawale\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Dattatray Dhawale\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"17 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/mobisoftinfotech.com\/resources\/blog\/microservices\/resilience4j-circuit-breaker-retry-bulkhead-spring-boot#article\",\"isPartOf\":{\"@id\":\"https:\/\/mobisoftinfotech.com\/resources\/blog\/microservices\/resilience4j-circuit-breaker-retry-bulkhead-spring-boot\"},\"author\":{\"name\":\"Dattatray Dhawale\",\"@id\":\"https:\/\/mobisoftinfotech.com\/resources\/#\/schema\/person\/038e7f28f9722a8f9c662da7c1562bcc\"},\"headline\":\"Resilience4j Circuit Breaker Tutorial along with Retry &amp; Bulkhead patterns for Spring Boot Microservices\",\"datePublished\":\"2025-06-13T15:23:43+00:00\",\"dateModified\":\"2025-11-04T05:06:34+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/mobisoftinfotech.com\/resources\/blog\/microservices\/resilience4j-circuit-breaker-retry-bulkhead-spring-boot\"},\"wordCount\":3165,\"image\":{\"@id\":\"https:\/\/mobisoftinfotech.com\/resources\/blog\/microservices\/resilience4j-circuit-breaker-retry-bulkhead-spring-boot#primaryimage\"},\"thumbnailUrl\":\"https:\/\/mobisoftinfotech.com\/resources\/wp-content\/uploads\/2025\/06\/resilience4j-circuit-breaker-retry-bulkhead-spring-boot.png\",\"keywords\":[\"bulkhead pattern in microservices\",\"circuit breaker pattern in microservices\",\"circuit breaker resilience4j 90\",\"how to use resilience4j\",\"microservices resilience 20\",\"microservices resilience patterns\",\"resilience in microservices 150\",\"resilience patterns in java\",\"resilience patterns in microservices 30\",\"resilience4j bulkhead pattern\",\"resilience4j circuit breaker\",\"resilience4j retry mechanism\",\"retry pattern in microservices\"],\"articleSection\":[\"Microservices\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/mobisoftinfotech.com\/resources\/blog\/microservices\/resilience4j-circuit-breaker-retry-bulkhead-spring-boot\",\"url\":\"https:\/\/mobisoftinfotech.com\/resources\/blog\/microservices\/resilience4j-circuit-breaker-retry-bulkhead-spring-boot\",\"name\":\"Resilience4j Circuit Breaker, Retry & Bulkhead Tutorial\",\"isPartOf\":{\"@id\":\"https:\/\/mobisoftinfotech.com\/resources\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/mobisoftinfotech.com\/resources\/blog\/microservices\/resilience4j-circuit-breaker-retry-bulkhead-spring-boot#primaryimage\"},\"image\":{\"@id\":\"https:\/\/mobisoftinfotech.com\/resources\/blog\/microservices\/resilience4j-circuit-breaker-retry-bulkhead-spring-boot#primaryimage\"},\"thumbnailUrl\":\"https:\/\/mobisoftinfotech.com\/resources\/wp-content\/uploads\/2025\/06\/resilience4j-circuit-breaker-retry-bulkhead-spring-boot.png\",\"datePublished\":\"2025-06-13T15:23:43+00:00\",\"dateModified\":\"2025-11-04T05:06:34+00:00\",\"author\":{\"@id\":\"https:\/\/mobisoftinfotech.com\/resources\/#\/schema\/person\/038e7f28f9722a8f9c662da7c1562bcc\"},\"description\":\"Learn how to implement Resilience4j Circuit Breaker, Retry & Bulkhead patterns in Spring Boot microservices for resilient fault-tolerant applications.\",\"breadcrumb\":{\"@id\":\"https:\/\/mobisoftinfotech.com\/resources\/blog\/microservices\/resilience4j-circuit-breaker-retry-bulkhead-spring-boot#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/mobisoftinfotech.com\/resources\/blog\/microservices\/resilience4j-circuit-breaker-retry-bulkhead-spring-boot\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/mobisoftinfotech.com\/resources\/blog\/microservices\/resilience4j-circuit-breaker-retry-bulkhead-spring-boot#primaryimage\",\"url\":\"https:\/\/mobisoftinfotech.com\/resources\/wp-content\/uploads\/2025\/06\/resilience4j-circuit-breaker-retry-bulkhead-spring-boot.png\",\"contentUrl\":\"https:\/\/mobisoftinfotech.com\/resources\/wp-content\/uploads\/2025\/06\/resilience4j-circuit-breaker-retry-bulkhead-spring-boot.png\",\"width\":855,\"height\":392,\"caption\":\"resilience4j circuit breaker tutorial for spring boot microservices\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/mobisoftinfotech.com\/resources\/blog\/microservices\/resilience4j-circuit-breaker-retry-bulkhead-spring-boot#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/mobisoftinfotech.com\/resources\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Resilience4j Circuit Breaker Tutorial along with Retry &amp; Bulkhead patterns for Spring Boot Microservices\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/mobisoftinfotech.com\/resources\/#website\",\"url\":\"https:\/\/mobisoftinfotech.com\/resources\/\",\"name\":\"Mobisoft Infotech\",\"description\":\"Discover Mobility\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/mobisoftinfotech.com\/resources\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/mobisoftinfotech.com\/resources\/#\/schema\/person\/038e7f28f9722a8f9c662da7c1562bcc\",\"name\":\"Dattatray Dhawale\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/secure.gravatar.com\/avatar\/6c870d9e909d81d7f973503a08ca66afd65dcb3882140c657957c7653d4c7223?s=96&r=g\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/6c870d9e909d81d7f973503a08ca66afd65dcb3882140c657957c7653d4c7223?s=96&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/6c870d9e909d81d7f973503a08ca66afd65dcb3882140c657957c7653d4c7223?s=96&r=g\",\"caption\":\"Dattatray Dhawale\"},\"sameAs\":[\"https:\/\/mobisoftinfotech.com\/\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Resilience4j Circuit Breaker, Retry & Bulkhead Tutorial","description":"Learn how to implement Resilience4j Circuit Breaker, Retry & Bulkhead patterns in Spring Boot microservices for resilient fault-tolerant applications.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/mobisoftinfotech.com\/resources\/blog\/microservices\/resilience4j-circuit-breaker-retry-bulkhead-spring-boot","og_locale":"en_US","og_type":"article","og_title":"Resilience4j Circuit Breaker, Retry & Bulkhead Tutorial","og_description":"Learn how to implement Resilience4j Circuit Breaker, Retry & Bulkhead patterns in Spring Boot microservices for resilient fault-tolerant applications.","og_url":"https:\/\/mobisoftinfotech.com\/resources\/blog\/microservices\/resilience4j-circuit-breaker-retry-bulkhead-spring-boot","og_site_name":"Mobisoft Infotech","article_published_time":"2025-06-13T15:23:43+00:00","article_modified_time":"2025-11-04T05:06:34+00:00","og_image":[{"width":1000,"height":525,"url":"https:\/\/mobisoftinfotech.com\/resources\/wp-content\/uploads\/2025\/06\/og-Resilience4j-Circuit-Breaker-Tutorial.png","type":"image\/png"}],"author":"Dattatray Dhawale","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Dattatray Dhawale","Est. reading time":"17 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/mobisoftinfotech.com\/resources\/blog\/microservices\/resilience4j-circuit-breaker-retry-bulkhead-spring-boot#article","isPartOf":{"@id":"https:\/\/mobisoftinfotech.com\/resources\/blog\/microservices\/resilience4j-circuit-breaker-retry-bulkhead-spring-boot"},"author":{"name":"Dattatray Dhawale","@id":"https:\/\/mobisoftinfotech.com\/resources\/#\/schema\/person\/038e7f28f9722a8f9c662da7c1562bcc"},"headline":"Resilience4j Circuit Breaker Tutorial along with Retry &amp; Bulkhead patterns for Spring Boot Microservices","datePublished":"2025-06-13T15:23:43+00:00","dateModified":"2025-11-04T05:06:34+00:00","mainEntityOfPage":{"@id":"https:\/\/mobisoftinfotech.com\/resources\/blog\/microservices\/resilience4j-circuit-breaker-retry-bulkhead-spring-boot"},"wordCount":3165,"image":{"@id":"https:\/\/mobisoftinfotech.com\/resources\/blog\/microservices\/resilience4j-circuit-breaker-retry-bulkhead-spring-boot#primaryimage"},"thumbnailUrl":"https:\/\/mobisoftinfotech.com\/resources\/wp-content\/uploads\/2025\/06\/resilience4j-circuit-breaker-retry-bulkhead-spring-boot.png","keywords":["bulkhead pattern in microservices","circuit breaker pattern in microservices","circuit breaker resilience4j 90","how to use resilience4j","microservices resilience 20","microservices resilience patterns","resilience in microservices 150","resilience patterns in java","resilience patterns in microservices 30","resilience4j bulkhead pattern","resilience4j circuit breaker","resilience4j retry mechanism","retry pattern in microservices"],"articleSection":["Microservices"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/mobisoftinfotech.com\/resources\/blog\/microservices\/resilience4j-circuit-breaker-retry-bulkhead-spring-boot","url":"https:\/\/mobisoftinfotech.com\/resources\/blog\/microservices\/resilience4j-circuit-breaker-retry-bulkhead-spring-boot","name":"Resilience4j Circuit Breaker, Retry & Bulkhead Tutorial","isPartOf":{"@id":"https:\/\/mobisoftinfotech.com\/resources\/#website"},"primaryImageOfPage":{"@id":"https:\/\/mobisoftinfotech.com\/resources\/blog\/microservices\/resilience4j-circuit-breaker-retry-bulkhead-spring-boot#primaryimage"},"image":{"@id":"https:\/\/mobisoftinfotech.com\/resources\/blog\/microservices\/resilience4j-circuit-breaker-retry-bulkhead-spring-boot#primaryimage"},"thumbnailUrl":"https:\/\/mobisoftinfotech.com\/resources\/wp-content\/uploads\/2025\/06\/resilience4j-circuit-breaker-retry-bulkhead-spring-boot.png","datePublished":"2025-06-13T15:23:43+00:00","dateModified":"2025-11-04T05:06:34+00:00","author":{"@id":"https:\/\/mobisoftinfotech.com\/resources\/#\/schema\/person\/038e7f28f9722a8f9c662da7c1562bcc"},"description":"Learn how to implement Resilience4j Circuit Breaker, Retry & Bulkhead patterns in Spring Boot microservices for resilient fault-tolerant applications.","breadcrumb":{"@id":"https:\/\/mobisoftinfotech.com\/resources\/blog\/microservices\/resilience4j-circuit-breaker-retry-bulkhead-spring-boot#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/mobisoftinfotech.com\/resources\/blog\/microservices\/resilience4j-circuit-breaker-retry-bulkhead-spring-boot"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/mobisoftinfotech.com\/resources\/blog\/microservices\/resilience4j-circuit-breaker-retry-bulkhead-spring-boot#primaryimage","url":"https:\/\/mobisoftinfotech.com\/resources\/wp-content\/uploads\/2025\/06\/resilience4j-circuit-breaker-retry-bulkhead-spring-boot.png","contentUrl":"https:\/\/mobisoftinfotech.com\/resources\/wp-content\/uploads\/2025\/06\/resilience4j-circuit-breaker-retry-bulkhead-spring-boot.png","width":855,"height":392,"caption":"resilience4j circuit breaker tutorial for spring boot microservices"},{"@type":"BreadcrumbList","@id":"https:\/\/mobisoftinfotech.com\/resources\/blog\/microservices\/resilience4j-circuit-breaker-retry-bulkhead-spring-boot#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/mobisoftinfotech.com\/resources\/"},{"@type":"ListItem","position":2,"name":"Resilience4j Circuit Breaker Tutorial along with Retry &amp; Bulkhead patterns for Spring Boot Microservices"}]},{"@type":"WebSite","@id":"https:\/\/mobisoftinfotech.com\/resources\/#website","url":"https:\/\/mobisoftinfotech.com\/resources\/","name":"Mobisoft Infotech","description":"Discover Mobility","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/mobisoftinfotech.com\/resources\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/mobisoftinfotech.com\/resources\/#\/schema\/person\/038e7f28f9722a8f9c662da7c1562bcc","name":"Dattatray Dhawale","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/6c870d9e909d81d7f973503a08ca66afd65dcb3882140c657957c7653d4c7223?s=96&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/6c870d9e909d81d7f973503a08ca66afd65dcb3882140c657957c7653d4c7223?s=96&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/6c870d9e909d81d7f973503a08ca66afd65dcb3882140c657957c7653d4c7223?s=96&r=g","caption":"Dattatray Dhawale"},"sameAs":["https:\/\/mobisoftinfotech.com\/"]}]}},"_links":{"self":[{"href":"https:\/\/mobisoftinfotech.com\/resources\/wp-json\/wp\/v2\/posts\/39594","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mobisoftinfotech.com\/resources\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mobisoftinfotech.com\/resources\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mobisoftinfotech.com\/resources\/wp-json\/wp\/v2\/users\/119"}],"replies":[{"embeddable":true,"href":"https:\/\/mobisoftinfotech.com\/resources\/wp-json\/wp\/v2\/comments?post=39594"}],"version-history":[{"count":28,"href":"https:\/\/mobisoftinfotech.com\/resources\/wp-json\/wp\/v2\/posts\/39594\/revisions"}],"predecessor-version":[{"id":44956,"href":"https:\/\/mobisoftinfotech.com\/resources\/wp-json\/wp\/v2\/posts\/39594\/revisions\/44956"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/mobisoftinfotech.com\/resources\/wp-json\/wp\/v2\/media\/39597"}],"wp:attachment":[{"href":"https:\/\/mobisoftinfotech.com\/resources\/wp-json\/wp\/v2\/media?parent=39594"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mobisoftinfotech.com\/resources\/wp-json\/wp\/v2\/categories?post=39594"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mobisoftinfotech.com\/resources\/wp-json\/wp\/v2\/tags?post=39594"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}