我正在使用 spring cloud 从另一个服务请求数据。所以,基本上我请求数据,我想检索该数据并将其分配给另一个对象,该对象将是我要保存的对象。
这是我的代码:
public Mono<Shops> save(Shops shops) {
Mono<Shops> s = webClientBuilder.build().get()
.uri("http://mysql-app/api/reservation-passengers/boarding-pass-data/" + shops.getBoardingPassId().toString())
.exchange()
.flatMap(response -> {
Shops myShops = response.bodyToMono(Shops.class).block();
shops.setAirportDestiny(myShops.getAirportDestiny());
shops.setCustomerId(myShops.getCustomerId());
return shopsRepository.save(shops);
});
return s;
}
但是我有一个例外:
java.lang.IllegalStateException: block()/blockFirst()/blockLast() are blocking, which is not supported in thread reactor-http-nio-7
如何从异步方法中获取数据?