日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 >

openFeign异步调用问题

發(fā)布時(shí)間:2024/3/24 32 豆豆
生活随笔 收集整理的這篇文章主要介紹了 openFeign异步调用问题 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

報(bào)錯(cuò)信息

java.lang.IllegalStateException: block()/blockFirst()/blockLast() are blocking, which is not supported in thread reactor-http-nio-3at reactor.core.publisher.BlockingSingleSubscriber.blockingGet(BlockingSingleSubscriber.java:83) ~[reactor-core-3.4.15.jar:3.4.15]Suppressed: reactor.core.publisher.FluxOnAssembly$OnAssemblyException: Error has been observed at the following site(s):*__checkpoint ? org.springframework.cloud.gateway.filter.WeightCalculatorWebFilter [DefaultWebFilterChain]*__checkpoint ? HTTP GET "/get" [ExceptionHandlingWebHandler]

版本:
springcloud alibaba 2021.0.1.0
springboot 2.7.0
gateway 3.1.1
openfeign 3.1.1
還原場(chǎng)景
網(wǎng)關(guān)服務(wù)通過openfeign調(diào)用授權(quán)服務(wù)

授權(quán)服務(wù)

@GetMapping("/get")public String openFeignApi(){return "asdgwe";}

網(wǎng)關(guān)服務(wù)

@SpringBootApplication @EnableDiscoveryClient @EnableFeignClients public class GatewayServerApplication {public static void main(String[] args) {SpringApplication.run(GatewayServerApplication.class, args);}} @Component @FeignClient(value = "oauth") public interface OauthFeign {@GetMapping("/get")String openFeignApi(); }

controller

@ResourceOauthFeign oauthFeign;@GetMapping("/get")public Object get() {return oauthFeign.openFeignApi();}

此時(shí)請(qǐng)求網(wǎng)關(guān)的/get就會(huì)報(bào)上面的錯(cuò)誤。
需要添加一些配置

  • 添加HttpMessageConverters的bean
  • @Configuration public class HttpMsgConverConfig {@Bean@ConditionalOnMissingBeanpublic HttpMessageConverters messageConverters(ObjectProvider<HttpMessageConverter<?>> converters) {return new HttpMessageConverters(converters.orderedStream().collect(Collectors.toList()));} }
  • 異步調(diào)用openfeign接口,修改controller
  • @ResourceOauthFeign oauthFeign;@GetMapping("/get")public Object get() {CompletableFuture<Object> completableFuture = CompletableFuture.supplyAsync(() -> {return oauthFeign.openFeignApi();});return completableFuture;}

    總結(jié)

    以上是生活随笔為你收集整理的openFeign异步调用问题的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。

    如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。