Consider a code:
private WebClient webClient;
public void some(MyObject myObject) {
return webClient.post()
.uri("/log/my-path")
.body(BodyInserters.fromObject(myObject))
.retrieve()
.bodyToMono(Void.class)
.subscribeOn(Schedulers.single());
}
This code "waits" when response "appears" and then completes. (E.g. retrieve() is called). but how not to wait for response? For example, I make request and return Mono.empty without waiting for response. How to do that?
P.S. A technique when request is sent without wating for response is called "fire and forget".
UPDATED
- Any mono functions like
thendoes not work. Because they invocated afterbodyToMonowhich "waits" until http response is comming. E.g. nothing (event async) is called untilbodyToMonocompletes. - "remove"
returnstatment also does not work. May be in somemainfunctions it works but not in Spring application. This does not wok becauseMonojust created in that case, but nobody run it. AnyMonomethods likemap, flatMapetc. is just funciton "setting" but not Mono running.