当前位置:网站首页>openFeign异步调用问题
openFeign异步调用问题
2022-07-29 04:09:00 【Java精灵儿】
报错信息
java.lang.IllegalStateException: block()/blockFirst()/blockLast() are blocking, which is not supported in thread reactor-http-nio-3
at 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
还原场景
网关服务通过openfeign调用授权服务
授权服务
@GetMapping("/get")
public String openFeignApi(){
return "asdgwe";
}
网关服务
@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
@Resource
OauthFeign oauthFeign;
@GetMapping("/get")
public Object get() {
return oauthFeign.openFeignApi();
}
此时请求网关的/get就会报上面的错误。
需要添加一些配置
- 添加
HttpMessageConverters的bean
@Configuration
public class HttpMsgConverConfig {
@Bean
@ConditionalOnMissingBean
public HttpMessageConverters messageConverters(ObjectProvider<HttpMessageConverter<?>> converters) {
return new HttpMessageConverters(converters.orderedStream().collect(Collectors.toList()));
}
}
- 异步调用openfeign接口,修改controller
@Resource
OauthFeign oauthFeign;
@GetMapping("/get")
public Object get() {
CompletableFuture<Object> completableFuture = CompletableFuture.supplyAsync(() -> {
return oauthFeign.openFeignApi();
});
return completableFuture;
}
边栏推荐
- Some problems about pointers
- 优炫数据库有办法查到主集群每天传给备集群的日志量吗?
- First knowledge of C language (3)
- 2021 sist summer camp experience + record post of School of information, Shanghai University of science and technology
- SQL window function
- MySQL Part 4 (end)
- Big manufacturers finally can't stand "adding one second", and companies such as Microsoft, Google meta propose to abolish leap seconds
- The data source is SQL server. I want to configure the incremental data of the last two days of the date field updatedate to add
- Configmap configuration and secret encryption
- The difference between dynamic, VaR and object in fluent
猜你喜欢
随机推荐
The table of antd hides the pager when there is only one page
I. creation and constraint of MySQL table
[BGP] small scale experiment
MySQL Part 4 (end)
[deep learning CPU (part outside) - virtual memory]
How to write SQL statements about field conversion
全屋WiFi方案:Mesh路由器组网和AC+AP
"Weilai Cup" 2022 Niuke summer multi school training camp 1 J serval and essay (heuristic merger)
开课!看smardaten如何分解复杂业务场景
AssertionError(“Torch not compiled with CUDA enabled“)
基于STM32和阿里云的环境检测系统设计
Lua language (stm32+2g/4g module) and C language (stm32+esp8266) methods of extracting relevant data from strings - collation
Lucifer 98 life record ing
Const read only variable constant
"Weilai Cup" 2022 Niuke summer multi school training camp 2H
BIO、NIO、AIO的区别和原理
Do you have a boss to help me check whether the parameter configuration of the Flink SQL connection Kafka authentication Kerberos is wrong
Press the missing number of interview question 17.04 | | 260. the number that appears only once (including bit operation knowledge points)
[kvm] common commands
通过PWM呼吸灯和PWM控制直流电机来详细介绍TIM的输出比较功能









