阿帕奇骆驼。 FluentProducerTemplate 与 netty-http 组件。带有超时的请求方法不起作用

问题描述 投票:0回答:1

情况如下。

我正在尝试将请求发送到错误的IP,并想捕获请求超时异常。

虽然我向错误的IP发送了请求,但还是正常结束了。

来源如下。

try {

  FluentProducerTemplate fluentProducerTemplate = exchange.getContext().createFluentProducerTemplate();

  log.debug("START");

// 111.111.111.111:1111 is wrong IP sample
  Message message = fluentProducerTemplate.to("netty-http:http://111.111.111.111:1111/?clientMode=true&connectTimeout=5000").request(Message.class);

  log.debug("DONE");

} catch ( Exception e ) {

  log.debug("FAIL");
  
}

我认为应该以“FAIL”结束,但事实并非如此。从“START”开始 5 秒后打印日志消息“DONE”。并且回复消息为空。

连接超时有什么办法可以例外吗?

java apache-camel netty4
1个回答
0
投票

我尝试了一切方法来解决这个问题,但最终还是失败了。您可以使用ProducerTemplate代替FluentProducerTemplate来解决问题。

© www.soinside.com 2019 - 2024. All rights reserved.