当前位置:网站首页>Openfeign asynchronous call problem
Openfeign asynchronous call problem
2022-07-29 04:11:00 【Java Genie】
Error message
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]
edition :
springcloud alibaba 2021.0.1.0
springboot 2.7.0
gateway 3.1.1
openfeign 3.1.1
Restore scene
The gateway service passes through openfeign Call authorization service
Authorized service
@GetMapping("/get")
public String openFeignApi(){
return "asdgwe";
}
Gateway service
@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();
}
Request the gateway's /get
They will report the above mistakes .
You need to add some configuration
- add to
HttpMessageConverters
Of bean
@Configuration
public class HttpMsgConverConfig {
@Bean
@ConditionalOnMissingBean
public HttpMessageConverters messageConverters(ObjectProvider<HttpMessageConverter<?>> converters) {
return new HttpMessageConverters(converters.orderedStream().collect(Collectors.toList()));
}
}
- Asynchronous call openfeign Interface , modify controller
@Resource
OauthFeign oauthFeign;
@GetMapping("/get")
public Object get() {
CompletableFuture<Object> completableFuture = CompletableFuture.supplyAsync(() -> {
return oauthFeign.openFeignApi();
});
return completableFuture;
}
边栏推荐
猜你喜欢
信号处理中的反傅里叶变换(IFFT)原理
Const char* and char*, string constants
小程序:区域滚动、下拉刷新、上拉加载更多
First knowledge of C language (3)
Data mining -- code implementation of association analysis example (Part 2)
全屋WiFi方案:Mesh路由器组网和AC+AP
Lvs+keepalived high availability deployment practical application
Why are there so many unknowns when opengauss starts?
Design of environment detection system based on STM32 and Alibaba cloud
Lua language (stm32+2g/4g module) and C language (stm32+esp8266) methods of extracting relevant data from strings - collation
随机推荐
Simple cases of inner connection and left connection
Const read only variable constant
What the hell is this error? It doesn't affect the execution result, but it always reports errors when executing SQL... Connecting maxcomputer uses
Summary on the thought of double pointer
The difference between dynamic, VaR and object in fluent
rman不标记过期备份
flink-sql 如何设置 sql执行超时时间
[deep learning CPU (part outside) - virtual memory]
LDP -- label distribution protocol
[untitled]
Pointer of pointer???...
[principle] several ways of horizontal penetration
The output comparison function of Tim is introduced in detail through PWM breathing lamp and PWM controlled DC motor
Const char* and char*, string constants
C language - character array - string array - '\0' -sizeof-strlen() -printf()
Three tier architecture of enterprise network
Pointer variables -printf%d and%p meaning
The structure pointer must be initialized, and the pointer must also be initialized
"Weilai Cup" 2022 Niuke summer multi school training camp 2H
企业网的三层架构