Resttemplate - 无法连接:超时我不应该在这里

时间:2016-12-23 07:46:59

标签: spring spring-boot apache-camel

我在这个json响应中得到了一些超时消息,并且该类抛出了无效的jSON异常。

Json回复

failed to connect: timeout I should not be here {Valid json}

但是当我通过邮递员测试时,我看不到那令人沮丧的消息。

我正在使用spring RestTemplate`来调用服务

final HttpEntity<String> entity = new HttpEntity<String>(headers);
    final ResponseEntity<String> exchange = restTemplate.exchange(uri.toUriString(),
            HttpMethod.GET, entity, String.class);

即使我增加超时值,它也是相同的

@PostConstruct
public void init() {
    restTemplate = new RestTemplate(clientHttpRequestFactory());
    restTemplate.setErrorHandler(new DefaultResponseErrorHandler() {
        protected boolean hasError(HttpStatus statusCode) {
            return false;
        }
    });

}

private ClientHttpRequestFactory clientHttpRequestFactory() {
    HttpComponentsClientHttpRequestFactory factory = new HttpComponentsClientHttpRequestFactory();
    factory.setReadTimeout(10000);
    factory.setConnectTimeout(10000);
    return factory;
}

这是我的骆驼路线

    from("direct:processRequest").process(new RecipientListBean()).recipientList(header("recipients"))
            .aggregationStrategy(aggregationStrategy)
            .parallelProcessing()
            .to("bean:transformerBean");

0 个答案:

没有答案