Skip to content

Instantly share code, notes, and snippets.

@eldermoraes
Last active December 17, 2022 19:15
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eldermoraes/f239294539d40d07a1282c2e93fd3227 to your computer and use it in GitHub Desktop.
Save eldermoraes/f239294539d40d07a1282c2e93fd3227 to your computer and use it in GitHub Desktop.
@Path("/circuit")
public class CircuitResource {
@Timeout(unit = ChronoUnit.MILLIS, value = 500)
@Fallback(fallbackMethod = "fallback")
@CircuitBreaker(requestVolumeThreshold = 4, failureRatio = 0.5, delay = 2000, delayUnit = ChronoUnit.MILLIS, successThreshold = 2)
@GET
public String getCircuit() throws InterruptedException {
Thread.sleep(600);
return "Circuit \n";
}
private String fallback(){
return "I'm a fallback ";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment