How I Decoupled Circuit Breaker from the Code with AOP in Spring Boot for Better Code Maintenance

What I’m gonna do today,

What I’m NOT gonna do today,

What you’ll need,

What is AOP (Aspect Oriented Programming),

What is a Join Point,

What is Around Advice,

Creating the Application


Mandatory imports,

Creating the Service Layer,

Creating the Controller,

Creating the Rest Controller Advice,

AOP Around Advice Implementation,

How would Service Layer Looks Like if we Implemented Circuit Breaker without AOP,

return Decorators.ofSupplier(supplier)

How AOP Logic Should be Implemented,

Object proceed() throws Throwable;
public interface Supplier<T> {
T get();

Let’s Make that Custom Supplier,

Here’s the Configs for Resilience4j,

Let’s Create that Mockoon

test API call
testslow API call
testerror API call

Let’s Test It,

There you have it,


Further Reads,

I Am a Passionate Software Engineer

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store