In the below code, the save to retrivedPrev and retrivedNext marked as //1 and //2 are not getting saved using Mongo reactive and control is only saving retrievedPortCall marked as //3. Pls suggest how can I achieve the same using Spring Webflux. If I use block(), I get Exception - block() is blocking which is not supported by thread reactor http-nio-2
public Mono<PortCall> updateByFindById(String gsisKey, PortCall portCall) {
PortCall nextPort = portCallRepository.findById(portCall.getNextPortCall().getNextScheduleEntryKey()).toProcessor().block();
PortCall prevPort = portCallRepository.findById(portCall.getPreviousPortCall().getPreviousScheduleEntryKey()).toProcessor().block();
Mono<PortCall> prev = portCallRepository.findById(portCall.getPreviousPortCall()
.getPreviousScheduleEntryKey()).flatMap(retrivedPrev -> {
retrivedPrev.getNextPortCall().setNextScheduleEntryKey(nextPort.getGsisKey());
retrivedPrev.getNextPortCall().setTerminalCode(nextPort.getSiteRkstCode());
return portCallRepository.save(retrivedPrev); //1
});
Mono<PortCall> next = portCallRepository.findById(portCall.getNextPortCall()
.getNextScheduleEntryKey()).flatMap(retrivedNext->{
retrivedNext.getPreviousPortCall().setPreviousScheduleEntryKey(prevPort.getGsisKey());
retrivedNext.getPreviousPortCall().setTerminalCode(prevPort.getSiteRkstCode());
return portCallRepository.save(retrivedNext); //2
});
return portCallRepository.findById(gsisKey)
.flatMap(retrivedPortCall -> {
retrivedPortCall.setSiteCallStatus(SiteCallStatus.DELETED);
return portCallRepository.save(retrivedPortCall) //3
});
}
@Transactional
annotation. – Rafael Guillen