Is this the correct way to handle reactively? I see 2 threads one reactive nio which is until and including flatMap(fareRepo::save)
. The other thread is computations thread which starts from sending message and goes on till ServerResponse.build(). My question is this correct way to handle request reactively? Note: that fareRepo is reactive couchbase repo.
thanks
return request.bodyToMono(Fare.class).flatMap(fareRepo::save).flatMap(fs -> {
logger.info("sending message: {}, to queue", fs.getId());
jmsTemplate.send("fare-request-queue", (session) -> session.createTextMessage(fs.getId()));
return Mono.just(fs);
}).flatMap(fi -> ServerResponse.created(URI.create("/fare/" + fi.getId())).build());
fareRepo::save
is probably synchronous operation, so you kinda mixing non-blocking stuff and the blocking one. I would say it is not a good practice. – HarlequinadeflatMap
:) – Overcheck