当前位置:网站首页>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;
}
边栏推荐
- Solution: module 'xlrd' has no attribute 'open_ Error reporting of workbook '
- Methods of using multiple deformations on an element
- Asp.net MVC中文件夹中的控制器如何跳转到根目录的控制器中?
- When defining an array, the size must be constant
- Routing knowledge
- 数据库SQL语句实现数据分解的函数查询
- First ALV program 2
- Applet: Area scrolling, pull-down refresh, pull-up load more
- Pointer of pointer???...
- Install the laser of ROS_ scan_ Problems encountered in match library (I)
猜你喜欢

LDP -- label distribution protocol

MPU6050

Data mining -- code implementation of association analysis example (Part 2)

C language to achieve three chess game (detailed explanation)

Lvs+keepalived high availability deployment practical application
![[Openstack] keystone,nova](/img/de/70b654a29a813c8fe828c4018bd4e7.png)
[Openstack] keystone,nova

Ssl== certificate related concepts

Ma Zhixing entered the mass production of front loading, starting with the self-developed domain controller?

数据挖掘——关联分析例题代码实现(下)

Nacos registry
随机推荐
数据挖掘——关联分析基础介绍(上)
Data mining -- Introduction to the basis of association analysis (Part 1)
Svg -- loading animation
【BGP】小型实验
What the hell is this error? It doesn't affect the execution result, but it always reports errors when executing SQL... Connecting maxcomputer uses
当我从数据库获取到了winfrom特定的控件ID之后我需要通过这个ID找到对应的控件,并对控件的TEXT文本进行赋值这该怎么做
Solution: module 'xlrd' has no attribute 'open_ Error reporting of workbook '
[kvm] common commands
如何查询版本的提交号
Pointer variables -printf%d and%p meaning
Nacos registry
Const char* and char*, string constants
Mmdetection preliminary use
“蔚来杯“2022牛客暑期多校训练营2 H
Applet: Area scrolling, pull-down refresh, pull-up load more
MPU6050
BGP的基础配置---建立对等体、路由宣告
How to write the filter conditions of data integration and what syntax to use? SQL syntax processing bizdate can not be
View partition table format
The output comparison function of Tim is introduced in detail through PWM breathing lamp and PWM controlled DC motor