Skip to content

Instantly share code, notes, and snippets.

@laguiar
Last active July 25, 2019 21:40
Show Gist options
  • Save laguiar/eeb06d807233310bc08f84767fe7fd7f to your computer and use it in GitHub Desktop.
Save laguiar/eeb06d807233310bc08f84767fe7fd7f to your computer and use it in GitHub Desktop.
Just a quick example with reactor
Flux.error<String>(RuntimeException())
.retryWhen { error ->
error.doOnNext { println(it) }
.zipWith(Flux.range(1, 4))
.map { tuple -> if (tuple.t2 < 4) tuple.t2 else throw Exceptions.propagate(tuple.t1) }
.flatMap { Mono.delay(Duration.ofMillis(it.toLong() * 1000)) }
.doOnNext { println("Retrying... ${LocalTime.now()}") }
}
.doOnError { println("Finished with ERROR!") }
.subscribe()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment