|
@@ -12,6 +12,7 @@ import org.java_websocket.WebSocket;
|
|
|
import org.java_websocket.client.WebSocketClient;
|
|
|
import org.java_websocket.handshake.ServerHandshake;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.scheduling.annotation.Scheduled;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
@@ -40,13 +41,23 @@ import lombok.extern.slf4j.Slf4j;
|
|
|
* // 项目启动的时候打开websocket连接
|
|
|
* webSocketClientFactory.retryOutCallWebSocketClient();
|
|
|
**/
|
|
|
-@Component
|
|
|
@Slf4j
|
|
|
+@Component
|
|
|
public class WebSocketClientFactory {
|
|
|
- ExecutorService executor = ExecutorBuilder.create()
|
|
|
- .setCorePoolSize(5)
|
|
|
- .setMaxPoolSize(10)
|
|
|
- .setWorkQueue(new LinkedBlockingQueue<>(102400))
|
|
|
+
|
|
|
+ @Value("${config.executor.core-pool-size:10}")
|
|
|
+ private int iotCorePoolSize = 10;
|
|
|
+
|
|
|
+ @Value("${config.executor.max-pool-size:20}")
|
|
|
+ private int iotMaxPoolSize = 20;
|
|
|
+
|
|
|
+ @Value("${config.executor.work-queue-size:204800}")
|
|
|
+ private int iotWorkQueueSize = 204800;
|
|
|
+
|
|
|
+ private ExecutorService executor = ExecutorBuilder.create()
|
|
|
+ .setCorePoolSize(iotCorePoolSize)
|
|
|
+ .setMaxPoolSize(iotMaxPoolSize)
|
|
|
+ .setWorkQueue(new LinkedBlockingQueue<>(iotWorkQueueSize))
|
|
|
.setHandler(new ThreadPoolExecutor.AbortPolicy())
|
|
|
.build();
|
|
|
|