Skip to content

Instantly share code, notes, and snippets.

@krnbr
Created September 1, 2021 19:58
Show Gist options
  • Save krnbr/aea89c7b9a15141a3a529adbc17b8717 to your computer and use it in GitHub Desktop.
Save krnbr/aea89c7b9a15141a3a529adbc17b8717 to your computer and use it in GitHub Desktop.
@CircuitBreaker(name = "mockService", fallbackMethod = "fallback")
public Mono<MockServiceResponse> getMockServiceResponse() {
return mockServiceWebClient.get()
.uri(DOWNSTREAM_PATH)
.retrieve()
.bodyToMono(MockServiceResponse.class)
.doOnError(ex -> {
throw new RuntimeException("the exception message is - "+ex.getMessage());
});
}
public Mono<MockServiceResponse> fallback(Throwable ex) {
//Arrays.stream(ex.getStackTrace()).forEach(System.out::println);
System.out.println("---> "+ex.getMessage());
MockServiceResponse mockServiceResponse = new MockServiceResponse();
mockServiceResponse.setError(true);
return Mono.just(mockServiceResponse);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment