I'm trying to wrap method with fromCallable to execute my method from another thread. But when i return as Mono.error
, my error consumer not catch any error when i subscribe to it. Instead it only prints Mono.error on my log. Am i doing it wrong?
Mono.fromCallable(()
-> Mono.error(new Exception("error coming")))
.subscribeOn(Schedulers.boundedElastic())
.doOnError(throwable -> LOG.debug("error {}",throwable.getMessage()))
.log()
.subscribe(res ->LOG.debug("result {}", res),
err -> LOG.error("Error message {}", err.getMessage()));
The Callable
passed to Mono.fromCallable(...)
should either:
throw
keyword).In other words, the Callable
should not return a Mono
or Flux
, which is what your example is doing.