当前位置:网站首页>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;
}
边栏推荐
- The output comparison function of Tim is introduced in detail through PWM breathing lamp and PWM controlled DC motor
- I. creation and constraint of MySQL table
- [Openstack] keystone,nova
- How to write SQL statements about field conversion
- MPU6050
- Rhel8 patch package production
- Some problems about pointers
- Lua语言(stm32+2G/4G模块)和C语言(stm32+esp8266)从字符串中提取相关数据的方法-整理
- “蔚来杯“2022牛客暑期多校训练营2 H
- Taobao product details interface (product details page data interface)
猜你喜欢
2021 sist summer camp experience + record post of School of information, Shanghai University of science and technology
nacos注册中心
[kvm] create virtual machine from kickstart file
编译与链接
Zhihuijun, a genius of Huawei, made a modular mechanical keyboard, which caused an earthquake in the geek circle. Netizens: This is the real customization
Big manufacturers finally can't stand "adding one second", and companies such as Microsoft, Google meta propose to abolish leap seconds
店铺排名问题,如何解决?
Design of environment detection system based on STM32 and Alibaba cloud
Configmap配置与Secret加密
Meeting notice of OA project (Query & whether to attend the meeting & feedback details)
随机推荐
What the hell is this error? It doesn't affect the execution result, but it always reports errors when executing SQL... Connecting maxcomputer uses
通过PWM呼吸灯和PWM控制直流电机来详细介绍TIM的输出比较功能
"Weilai Cup" 2022 Niuke summer multi school training camp 2H
STM32F103ZET6程序移植为C8T6+C8T6下载程序flash timeout的解决方案
Taobao product details interface (product details page data interface)
数据库SQL语句实现数据分解的函数查询
LCA 板子
C语言实现三子棋游戏(详解)
SQL server当存储过程接收的参数是int类型时,如何做判断?
Design of environment detection system based on STM32 and Alibaba cloud
Fu Yingna: Yuan universe is the new generation of Internet!
有一种密码学专用语言叫做ASN.1
%s. %c, character constant, string constant, const char*, pointer array, string array summary
[kvm] install KVM
Copy products with one click from Taobao, tmall, 1688, wechat, jd.com, Suning, taote and other platforms to pinduoduo platform (batch upload baby details Interface tutorial)
Pointer constant and constant pointer
UnicodeDecodeError: ‘ascii‘ codec can‘t decode byte 0x90 in position 614: ordinal not in range(128)
Deep understanding of browser caching mechanism (HTTP)
How to execute insert into select from job in SQL client
opengauss预检查安装