Parcourir la source

******************WX *********************
修改任务为多线程

zhangweixin il y a 4 ans
Parent
commit
76146c5454

+ 3 - 3
datasyn/src/main/kotlin/com/persagy/server/syn/DataSynApp.kt

@@ -82,9 +82,9 @@ open class DataSynApp : SpringBootServletInitializer() {
  * @param   args        命令行参数
  */
 fun main(args: Array<String>) {
-    SHttpUtil.connectTimeout = 1560000
-    SHttpUtil.readTimeout = 1560000
-    SHttpUtil.writeTimeout = 1560000
+    SHttpUtil.connectTimeout = 560000
+    SHttpUtil.readTimeout = 560000
+    SHttpUtil.writeTimeout = 560000
     SpringApplication.run(DataSynApp::class.java, *args)
     return
 } // Function main()

+ 17 - 0
datasyn/src/main/kotlin/com/persagy/server/syn/task/ScheduledConfig.kt

@@ -0,0 +1,17 @@
+package com.persagy.server.syn.task
+
+import org.springframework.context.annotation.Configuration;
+import org.springframework.scheduling.annotation.SchedulingConfigurer;
+import org.springframework.scheduling.config.ScheduledTaskRegistrar;
+import java.util.concurrent.Executors
+
+
+/**
+ * 定时任务并行执行
+ */
+@Configuration
+open class ScheduledConfig : SchedulingConfigurer {
+    override fun configureTasks(scheduledTaskRegistrar: ScheduledTaskRegistrar) {
+        scheduledTaskRegistrar.setScheduler(Executors.newScheduledThreadPool(5));
+    }
+}