Resilience4J still jumping into fall back method after switching to disabled state

131 Views Asked by At

I am trying to test r4j changes, I want to be able to turn it off. I am using the transitionToDisabledState method but it is still jumping to fall back method although the state is disabled. Am I missing something here? Thanks in advance.

Sorry if below is a bit sloppy quickly wrote it out now

@autowired
private CircuitBreakerRegistry circuitBreakerRegistry;


@CircuitBreaker (name = "name", fallbackMethod = "fallbackMethod")
public void serviceName (String requestId) {
if (requestId.contains("test")){
throw new RuntimeException ("testing circuitBreaker");
}

if (requestId.contains("turnoff")){
disable( name: "name");
}
}


public void fallbackMethodO){
System.out.printin("inside fallback method");
}


public void disable (String name) {
circuitBreakerRegistry.circuitBreaker(name).transitionToDisabledState();
System.out.println("circuit breaker is disabled");
}

Expecting the fallback method not to be invoked after switching to disabled state.

0

There are 0 best solutions below