Skip to content

Instantly share code, notes, and snippets.

@ayushi24041992
Last active December 24, 2019 10:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ayushi24041992/23f18474287dda73df55fa69de8f21e5 to your computer and use it in GitHub Desktop.
Save ayushi24041992/23f18474287dda73df55fa69de8f21e5 to your computer and use it in GitHub Desktop.
@Test
public void fluxErrorHandling_withRetry(){
Flux<String> stringFlux = Flux.just("a","b","c")
.concatWith(Flux.error(new RuntimeException("Exception Occurred")))
.concatWith(Flux.just("D"))
.onErrorMap((e) -> new CustomException(e))
.retry(2);
// P.s. Retry produces same stream again
StepVerifier.create(stringFlux.log())
.expectSubscription()
.expectNext("a","b","c")
.expectNext("a","b","c")
.expectNext("a","b","c")
.expectError(CustomException.class)
.verify();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment