Forráskód Böngészése

改成并发运行

suntianwu 3 éve
szülő
commit
f3419e016f

+ 4 - 0
src/main/java/com/care/mqtt/schedule/MqttHeartbeatSchedule.java

@@ -6,6 +6,8 @@ import org.apache.logging.log4j.LogManager;
 import org.apache.logging.log4j.Logger;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.annotation.Configuration;
+import org.springframework.scheduling.annotation.Async;
+import org.springframework.scheduling.annotation.EnableAsync;
 import org.springframework.scheduling.annotation.EnableScheduling;
 import org.springframework.scheduling.annotation.Scheduled;
 
@@ -16,6 +18,7 @@ import org.springframework.scheduling.annotation.Scheduled;
  **/
 @Configuration
 @EnableScheduling
+@EnableAsync
 public class MqttHeartbeatSchedule {
     private static final Logger logger = LogManager.getLogger(MqttHeartbeatSchedule.class);
    @Autowired
@@ -23,6 +26,7 @@ public class MqttHeartbeatSchedule {
     /**
      * 5 分钟调用一次
      */
+    @Async
     @Scheduled(cron = "0 0/5 * * * ?")
     public void rotationDev() {
         try {

+ 4 - 0
src/main/java/com/care/mqtt/schedule/MqttMsgSchedule.java

@@ -8,6 +8,8 @@ import org.apache.logging.log4j.Logger;
 
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.annotation.Configuration;
+import org.springframework.scheduling.annotation.Async;
+import org.springframework.scheduling.annotation.EnableAsync;
 import org.springframework.scheduling.annotation.EnableScheduling;
 import org.springframework.scheduling.annotation.Scheduled;
 
@@ -19,6 +21,7 @@ import org.springframework.scheduling.annotation.Scheduled;
  **/
 @Configuration
 @EnableScheduling
+@EnableAsync
 public class MqttMsgSchedule {
     private static final Logger logger = LogManager.getLogger(MqttMsgSchedule.class);
    @Autowired
@@ -26,6 +29,7 @@ public class MqttMsgSchedule {
     /**
      * 10 秒钟调用一次
      */
+    @Async
     @Scheduled(cron = "0/10 * * * * ?")
     public void rotationRedis() {
         try {

+ 4 - 0
src/main/java/com/care/outcall/schedule/KoalaOutCallBillSchedule.java

@@ -11,6 +11,8 @@ import org.apache.logging.log4j.LogManager;
 import org.apache.logging.log4j.Logger;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.annotation.Configuration;
+import org.springframework.scheduling.annotation.Async;
+import org.springframework.scheduling.annotation.EnableAsync;
 import org.springframework.scheduling.annotation.EnableScheduling;
 
 import org.springframework.scheduling.annotation.Scheduled;
@@ -24,6 +26,7 @@ import java.util.*;
  **/
 @Configuration
 @EnableScheduling
+@EnableAsync
 public class KoalaOutCallBillSchedule {
     private static final Logger logger = LogManager.getLogger(KoalaOutCallBillSchedule.class);
 
@@ -34,6 +37,7 @@ public class KoalaOutCallBillSchedule {
     /**
      * 10 秒钟调用一次
      */
+   //@Async
     //@Scheduled(cron = "0/10 * * * * ?")
     public void exePhoneBill() {
         try {