-1

I'm using a spring boot application with Webflux.

I need to retry the request if i get some error, but also, I need to check if an object property is true. This property is a boolean to check if i can retry.

Example:

webClient
        .post()
        .uri(object.getUrl())
        .body(BodyInserters.fromValue(docRequest))
        .retrieve()
        .bodyToMono(Document.class)
        .retry()
        .filter(e -> object.isRetry())

i tried this way but the filter is not working.

There is any way to filter?

Martin Tarjányi
  • 8,863
  • 2
  • 31
  • 49

1 Answers1

0

you could use the more advanced features of retryWhen

Never done this before, but reading the reference guide this might work:

.retryWhen(Retry.from(companion -> companion.filter(it -> object.isRetry())));

p.streef
  • 3,652
  • 3
  • 26
  • 50