Browse Source

修改线程数配置

liuam 7 years ago
parent
commit
91d9389352

+ 13 - 8
src/main/java/com/uas/ps/inquiry/http/HttpClientSpringFactory.java

@@ -27,6 +27,7 @@ import javax.net.ssl.SSLException;
 import javax.net.ssl.SSLHandshakeException;
 import java.io.IOException;
 import java.io.InterruptedIOException;
+import java.net.SocketException;
 
 /**
  * http 同步连接池、http 异步连接池,与spring集成
@@ -125,22 +126,26 @@ public class HttpClientSpringFactory {
             public boolean retryRequest(IOException exception,
                                         int executionCount, HttpContext context) {
                 logger.info("http request occurs error:{}", exception.getMessage());
-                if (executionCount >= 5) {// 如果已经重试了5次,就放弃
+                if (executionCount >= 3000) {// 如果已经重试了3000次,就放弃
                     return false;
                 }
-                if (exception instanceof NoHttpResponseException) {// 如果服务器丢掉了连接,那么就重试
-                    return true;
-                }
                 if (exception instanceof SSLHandshakeException) {// 不要重试SSL握手异常
                     return false;
                 }
-                if (exception instanceof InterruptedIOException) {// 超时
-                    return false;
-                }
                 if (exception instanceof SSLException) {// SSL握手异常
                     return false;
                 }
 
+                if (exception instanceof NoHttpResponseException) {// 如果服务器丢掉了连接,那么就重试
+                    return true;
+                }
+                if (exception instanceof InterruptedIOException) {// 超时
+                    return true;
+                }
+                if (exception instanceof SocketException) {
+                    return true;
+                }
+
                 HttpClientContext clientContext = HttpClientContext
                         .adapt(context);
                 HttpRequest request = clientContext.getRequest();
@@ -148,7 +153,7 @@ public class HttpClientSpringFactory {
                 if (!(request instanceof HttpEntityEnclosingRequest)) {
                     return true;
                 }
-                return false;
+                return true;
             }
         };
 

+ 1 - 1
src/main/java/com/uas/ps/inquiry/util/ThreadUtils.java

@@ -223,7 +223,7 @@ public class ThreadUtils {
 		}
 
 		private Executor() {
-			this.threadPool = Executors.newFixedThreadPool(1000);
+			this.threadPool = Executors.newFixedThreadPool(32);
 		}
 
 		public Executor setTimeout(int timeout) {

+ 2 - 2
src/main/resources/config/application-cloud.properties

@@ -29,11 +29,11 @@ message.senderEnuu=10042875
 http.asyncConnectTimeout=30000
 http.asyncSocketTimeout=30000
 http.asyncConnectionRequestTimeout=10000
-http.asyncConnectNum=500
+http.asyncConnectNum=50
 http.asyncConnectPerRoute=10
 http.asyncIoThreadCount=500
 http.syncConnectTimeout=60000
 http.syncSocketTimeout=60000
 http.syncConnectionRequestTimeout=10000
 http.syncConnectPerRoute=10
-http.syncConnectNum=1000
+http.syncConnectNum=100

+ 2 - 2
src/main/resources/config/application-dev.properties

@@ -32,13 +32,13 @@ message.senderEnuu=10043516
 http.asyncConnectTimeout=30000
 http.asyncSocketTimeout=30000
 http.asyncConnectionRequestTimeout=10000
-http.asyncConnectNum=500
+http.asyncConnectNum=50
 http.asyncConnectPerRoute=10
 http.asyncIoThreadCount=500
 http.syncConnectTimeout=60000
 http.syncSocketTimeout=60000
 http.syncConnectionRequestTimeout=10000
 http.syncConnectPerRoute=10
-http.syncConnectNum=1000
+http.syncConnectNum=100
 
 

+ 2 - 2
src/main/resources/config/application-test.properties

@@ -29,11 +29,11 @@ message.senderEnuu=10043516
 http.asyncConnectTimeout=30000
 http.asyncSocketTimeout=30000
 http.asyncConnectionRequestTimeout=10000
-http.asyncConnectNum=500
+http.asyncConnectNum=50
 http.asyncConnectPerRoute=10
 http.asyncIoThreadCount=500
 http.syncConnectTimeout=60000
 http.syncSocketTimeout=60000
 http.syncConnectionRequestTimeout=10000
 http.syncConnectPerRoute=10
-http.syncConnectNum=1000
+http.syncConnectNum=100

+ 2 - 2
src/main/resources/config/application-txcloud.properties

@@ -30,11 +30,11 @@ message.senderEnuu=10042875
 http.asyncConnectTimeout=30000
 http.asyncSocketTimeout=30000
 http.asyncConnectionRequestTimeout=10000
-http.asyncConnectNum=500
+http.asyncConnectNum=50
 http.asyncConnectPerRoute=10
 http.asyncIoThreadCount=500
 http.syncConnectTimeout=60000
 http.syncSocketTimeout=60000
 http.syncConnectionRequestTimeout=10000
 http.syncConnectPerRoute=10
-http.syncConnectNum=1000
+http.syncConnectNum=100