春季启动+ AWS Linux + Oracle数据库

时间:2018-10-30 04:57:33

标签: java linux spring-boot amazon-ec2 oracle11g

我已经在Oracle11g作为数据库的AWS Linux上使用JPA开发了Spring Boot REST API,因为我们正在处理Spring Boot,所以我们不必关心连接。

netstat -n | grep 1521   

当我触发此命令以检查所有连接是否都关闭时,我可以看到许多连接处于CLOSE_WAIT状态。
任何人都可以建议在Tomcat或Apache的应用程序或配置中出什么问题吗?

application.properties

spring.datasource.remove-abandoned=true  
spring.datasource.remove-abandoned-timeout=30  
spring.datasource.max-active=50  
spring.datasource.max-idle=8  
spring.datasource.min-idle=8  
spring.datasource.initial-size=10  
spring.datasource.max-wait=10000

1 个答案:

答案 0 :(得分:0)

问题是HttpResponse尚未关闭,要解决此问题,我使用了HttpClientUtils.closeQuietly,请参见下文:

HttpResponse response = null;
    try {
        response = client.execute(createHttpRequest(url, timeOut));
        StringBuilder result = new StringBuilder();
        try (BufferedReader rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()))) {
            String line;
            while ((line = rd.readLine()) != null) {
                result.append(line);
            }
        }
        return result;
    } catch (org.apache.http.conn.HttpHostConnectException e) {
        throw new HostUnreachableException(e);
    } finally {
        HttpClientUtils.closeQuietly(response);
    }