Java Spring RestTemplate超时配置不工作

Java Spring RestTemplate超时配置不工作,java,spring,resttemplate,hybris,Java,Spring,Resttemplate,Hybris,我有一个hybris应用程序,它使用rest模板调用restful API并使用json响应。我观察到,当应用程序在加载过程中多次点击api时,这些api的响应时间会显著增加。我已将超时设置为15秒,但是这些超时没有得到应用。连接仍然保持打开状态,并一直等待响应高达5分钟。我在日志中没有看到任何异常,因为需要这么长的时间,它也没有超时 下面是我用来设置超时的代码。我是否缺少任何设置来启用超时 public <E, T> E processService(String Url, fin

我有一个hybris应用程序,它使用rest模板调用restful API并使用json响应。我观察到,当应用程序在加载过程中多次点击api时,这些api的响应时间会显著增加。我已将超时设置为15秒,但是这些超时没有得到应用。连接仍然保持打开状态,并一直等待响应高达5分钟。我在日志中没有看到任何异常,因为需要这么长的时间,它也没有超时

下面是我用来设置超时的代码。我是否缺少任何设置来启用超时

public <E, T> E processService(String Url, final T serviceReq,
            final Class<E> serviceResponse, final HttpMethod 
httpMethod, final MediaType contentType,
            final Map<String, String> queryParams, final 
Map<String, String> header,
            final Map<String, String> pathVariables) throws 
Exception {
        RestTemplate restTemplate = getRestTemplate();
        setTimeoutProperties(restTemplate);
       <business logic to fire request and process response>}

private RestTemplate getRestTemplate() {
    if (LOG.isDebugEnabled()) {

getRestTemplate().setInterceptors(Collections.singletonList(new 
RequestResponseLoggingInterceptor()));
    }
    return getRestTemplate();
}



private void setTimeoutProperties(RestTemplate template) {
    final int readTimeout = configurationService.getConfiguration().getInteger("client.readtimeout",
            5000);
    final int connectTimeout = configurationService.getConfiguration()
            .getInteger("client.connectiontimeout", 5000);
    if (template.getRequestFactory() instanceof HttpComponentsClientHttpRequestFactory) {
        HttpComponentsClientHttpRequestFactory httpRequestFactory = (HttpComponentsClientHttpRequestFactory) template
                .getRequestFactory();
        httpRequestFactory.setConnectTimeout(connectTimeout);
        httpRequestFactory.setReadTimeout(readTimeout);     
        httpRequestFactory.setConnectionRequestTimeout(connectTimeout);

    } 
}
public E processService(字符串Url,最终T serviceReq,
最终类serviceResponse,最终HttpMethod
httpMethod,最终媒体类型contentType,
最终地图查询参数,最终
地图标题,
最终映射路径(变量)抛出
例外情况{
RestTemplate RestTemplate=getRestTemplate();
SetTimeOutProperty(restTemplate);
}
私有RestTemplate getRestTemplate(){
if(LOG.isDebugEnabled()){
getRestTemplate().setInterceptors(Collections.singletonList(新)
RequestResponseLogginInterceptor());
}
返回getRestTemplate();
}
私有void SetTimeOutProperty(RestTemplate模板){
final int readTimeout=configurationService.getConfiguration().getInteger(“client.readTimeout”,
5000);
final int connectTimeout=configurationService.getConfiguration()
.getInteger(“client.connectiontimeout”,5000);
if(HttpComponentsClientHttpRequestFactory的template.getRequestFactory()实例){
HttpComponents客户端httpRequestFactory httpRequestFactory=(HttpComponents客户端httpRequestFactory)模板
.getRequestFactory();
setConnectTimeout(connectTimeout);
setReadTimeout(readTimeout);
setConnectionRequestTimeout(connectTimeout);
} 
}

它甚至在打电话吗?它是否内存不足?为什么getRestTemplate()会调用自身?因为在生产环境中,繁忙的一天中,对API的调用数量大约为4000次/分钟,我怀疑连接池无法处理此类负载,请求在尝试从池本身获取连接时被卡住。对于如此大量的请求,是否有任何建议的连接池设置。还有getRestTemplate()调用intercept以记录发出的请求,以便进行故障排除。