소스 검색

增加弹性伸缩

dengsixing 3 주 전
부모
커밋
93a9484460
2개의 변경된 파일48개의 추가작업 그리고 9개의 파일을 삭제
  1. 6 0
      pom.xml
  2. 42 9
      src/main/java/com/fdkankan/contro/mq/service/impl/BuildSceneServiceImpl.java

+ 6 - 0
pom.xml

@@ -147,6 +147,12 @@
     </dependency>
 
     <dependency>
+      <groupId>com.fdkankan</groupId>
+      <artifactId>4dkankan-utils-rubber-sheeting</artifactId>
+      <version>3.0.0-SNAPSHOT</version>
+    </dependency>
+
+    <dependency>
       <groupId>net.lingala.zip4j</groupId>
       <artifactId>zip4j</artifactId>
       <version>1.3.2</version>

+ 42 - 9
src/main/java/com/fdkankan/contro/mq/service/impl/BuildSceneServiceImpl.java

@@ -37,10 +37,12 @@ import com.fdkankan.rabbitmq.bean.BuildSceneCallMessage;
 import com.fdkankan.rabbitmq.bean.BuildSceneResultMqMessage;
 import com.fdkankan.rabbitmq.util.RabbitMqProducer;
 import com.fdkankan.redis.util.RedisUtil;
+import com.fdkankan.rubbersheeting.ScalingService;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.ObjectUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.http.HttpHeaders;
+import org.springframework.amqp.rabbit.core.RabbitTemplate;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.cloud.context.config.annotation.RefreshScope;
@@ -81,6 +83,9 @@ public class BuildSceneServiceImpl implements IBuildSceneService {
     @Value("#{'${model.3dtiles.sceneSource:}'.split(',')}")
     private List<Integer> sdTilesSceneSourceList;
 
+    @Value("#{'${elastic:userIds:}'.split(',')}")
+    private List<Long> elasticUserIds;
+
     @Value("${env:gn}")
     private String env;
 
@@ -146,6 +151,10 @@ public class BuildSceneServiceImpl implements IBuildSceneService {
     private ILinkPanService linkPanService;
     @Autowired
     private IJmgaService jmgaService;
+    @Autowired
+    private ScalingService scalingService;
+    @Autowired
+    private RabbitTemplate rabbitTemplate;
 
 
     @Override
@@ -265,7 +274,22 @@ public class BuildSceneServiceImpl implements IBuildSceneService {
                 log.info("推送事件失败,param:{}", param);
             }
 
-            mqProducer.sendByWorkQueue(queueModelingCall, message);
+            boolean elastic = false;
+            if(CollUtil.isNotEmpty(elasticUserIds)){
+                ScenePlus scenePlus = scenePlusService.getScenePlusByNum(num);
+                if(elasticUserIds.contains(scenePlus.getUserId())){
+                    elastic = true;
+                }
+            }
+            if(elastic){
+                mqProducer.sendByWorkQueue("modeling-call-C", message);
+                Thread.sleep(10000L);
+                //查询队列是否存在堆积(未消费数>0)
+
+                //开启弹性伸缩
+            }else{
+                mqProducer.sendByWorkQueue(queueModelingCall, message);
+            }
 
             if(StrUtil.isNotEmpty(batchIds)){
                 origFileUploadBatchService.update(new LambdaUpdateWrapper<OrigFileUploadBatch>().set(OrigFileUploadBatch::getStatus, 1).in(OrigFileUploadBatch::getBatchId, batchIds.split(",")));
@@ -1170,14 +1194,23 @@ public class BuildSceneServiceImpl implements IBuildSceneService {
 //            System.out.println(s + ":" + detFloorplanObj.getBoolean(s));
 //
 //        }
-        try {
-           throw new BusinessException(345, "哈哈哈");
-        }catch (Exception e){
-            if(e instanceof  BusinessException){
-                System.out.println(((BusinessException) e).getCode());
-                System.out.println(((BusinessException) e).getMessage());
-            }
-        }
+//        try {
+//           throw new BusinessException(345, "哈哈哈");
+//        }catch (Exception e){
+//            if(e instanceof  BusinessException){
+//                System.out.println(((BusinessException) e).getCode());
+//                System.out.println(((BusinessException) e).getMessage());
+//            }
+//        }
+
+        Map<String, Object> params = new HashMap<>();
+        params.put("count", 5);
+        params.put("ackmode", "ack_requeue_true");
+        params.put("encoding", "auto");
+        String url = "http://119.23.182.50:15672/api/queues/vhost/name/get";
+        String s = HttpUtil.get(url, params);
+        System.out.println(s);
+
     }