我有一个如下所示的集成,我从rest控制器调用这个方法,但是应答超时并不像我预期的那样工作。
我期望的是:如果在我给出的回复超时时间内没有响应,则返回超时作为对客户端的响应。
通道配置中的超时时间需要做些什么吗?
谢谢。
@Gateway(requestChannel = REQUEST_CHANNEL, replyChannel = RESPONSE_CHANNEL, requestTimeout = 5000, replyTimeout = 5000)
Mono<ResponseObject> sendRequestObject(RequestObject request);
@Bean
public IntegrationFlow myRequestFlow() {
return IntegrationFlows.from(REQUEST_CHANNEL)
.enrichHeaders(HeaderEnricherSpec::headerChannelsToString)
.handle(message -> {
// I didn't send anything on the response channel.
System.out.println(message);
})
.get();
}
@Bean
public IntegrationFlow myResponseFlow(MessageChannel myResponseChannel) {
return IntegrationFlows.from(myResponseChannel)
.channel(RESPONSE_CHANNEL)
.get();
}发布于 2022-01-30 17:14:04
GatewayProxyFactoryBean当前的默认行为是在回复超时时返回null。逻辑是这样的:
if (reply == null && this.errorOnTimeout) {
throwMessageTimeoutException(object, "No reply received within timeout");
}默认情况下,errorOnTimeout是false,我看不出我们有一个从注释中提取的钩子来配置它。在这件事上自由地提出一个GH问题。
无论如何,我不认为replyTimeout与MonoReplyChannel有关。因此,从网关的角度来看,这可能是另一个改进。
但是我仍然认为您的web客户端应该设置一些请求超时,以避免无限期地等待。
https://stackoverflow.com/questions/70909843
复制相似问题