lyhzzz 1 год назад
Родитель
Сommit
1b246bf8cd
1 измененных файлов с 3 добавлено и 1 удалено
  1. 3 1
      src/main/java/com/fdkankan/mqcontroller/task/TaskService.java

+ 3 - 1
src/main/java/com/fdkankan/mqcontroller/task/TaskService.java

@@ -240,13 +240,15 @@ public class TaskService {
 
         Integer ecsCount = countMap.get(mqQueueConfig.getQueueName());
         MqMsg mqMsg = mqMsgMap.get(mqQueueConfig.getQueueName());
+        //时间判断
         Boolean flag = mqQueueConfig.getOpenScalingTime() == 0 || checkOpenCount  % (mqQueueConfig.getOpenScalingTime() * 6) == 0;
         //未在计算的服务器数量
         Integer noModelingCount = mqMsg.getConsumers() - mqMsg.getMessages_unacknowledged();
         //未启动的服务器数量
         Integer notStartCount = ecsCount - mqMsg.getConsumers();
+        Boolean flag2 = msgList.size()  >  mqQueueConfig.getScalingThreshold() + noModelingCount + notStartCount || (!msgList.isEmpty() &&  noModelingCount + notStartCount == 0 );
 
-        if(msgList.size()  >  mqQueueConfig.getScalingThreshold() + noModelingCount + notStartCount && flag){
+        if(flag2 && flag){
             log.info("将待开启弹性伸缩放入队列:{}",mqQueueConfig.getQueueName());
             MqScalingConfig mqScalingConfig = mqScalingConfigService.getById(mqQueueConfig.getScalingConfigId());
             DelEcsVo vo = new DelEcsVo(null,mqScalingConfig,mqQueueConfig.getQueueName());