|
@@ -1,5 +1,6 @@
|
|
|
package com.fdkankan.contro.mq.listener;
|
|
|
|
|
|
+import cn.hutool.core.thread.ThreadUtil;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.fdkankan.contro.mq.service.IBuildSceneProgressService;
|
|
|
import com.fdkankan.contro.mq.service.impl.BuildSceneServiceImpl;
|
|
@@ -14,6 +15,7 @@ import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
import java.nio.charset.StandardCharsets;
|
|
|
+import java.util.concurrent.*;
|
|
|
|
|
|
@Slf4j
|
|
|
@Component
|
|
@@ -40,7 +42,19 @@ public class BuildSceneProgressListener{
|
|
|
String msg = new String(message.getBody(), StandardCharsets.UTF_8);
|
|
|
log.info("开始推送场景计算进度,队列名:{},id:{},消息体:{}", queueName, messageId, msg);
|
|
|
BuildSceneCallMessage buildSceneMessage = JSONObject.parseObject(msg, BuildSceneCallMessage.class);
|
|
|
- buildSceneProgressService.monitorProgress(buildSceneMessage);
|
|
|
+ ExecutorService executor = ThreadUtil.newSingleExecutor();
|
|
|
+ Future future = executor.submit(() -> {
|
|
|
+ buildSceneProgressService.monitorProgress(buildSceneMessage);
|
|
|
+ });
|
|
|
+ try {
|
|
|
+ future.get(2*24*60*60, TimeUnit.SECONDS);
|
|
|
+ } catch (InterruptedException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ } catch (ExecutionException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ } catch (TimeoutException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
|
|
|
Thread.sleep(100000000);
|
|
|
log.info("推送场景计算进度完成,队列名:{},id:{},消息体:{}", queueName, messageId, msg);
|