|
@@ -0,0 +1,50 @@
|
|
|
|
|
+package com.hdkj.lt.mq.listener;
|
|
|
|
|
+
|
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
+import com.aliyun.openservices.ons.api.Action;
|
|
|
|
|
+import com.aliyun.openservices.ons.api.ConsumeContext;
|
|
|
|
|
+import com.aliyun.openservices.ons.api.Message;
|
|
|
|
|
+import com.aliyun.openservices.ons.api.MessageListener;
|
|
|
|
|
+import com.hdkj.hussar.ApiResponse;
|
|
|
|
|
+import com.hdkj.lt.feign.ISimulationPlatformApiClient;
|
|
|
|
|
+import com.hdkj.lt.modle.dto.simulation.QueryOperationModeDTO;
|
|
|
|
|
+import lombok.RequiredArgsConstructor;
|
|
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
+import org.springframework.stereotype.Component;
|
|
|
|
|
+
|
|
|
|
|
+import java.nio.charset.StandardCharsets;
|
|
|
|
|
+
|
|
|
|
|
+/**
|
|
|
|
|
+ * @author Annie
|
|
|
|
|
+ */
|
|
|
|
|
+@Slf4j
|
|
|
|
|
+@Component
|
|
|
|
|
+@RequiredArgsConstructor
|
|
|
|
|
+public class RocketConsumerSimulationTaskListener implements MessageListener {
|
|
|
|
|
+
|
|
|
|
|
+ private final ISimulationPlatformApiClient simulationPlatformApiClient;
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public Action consume(Message message, ConsumeContext consumeContext) {
|
|
|
|
|
+ try {
|
|
|
|
|
+ log.info("===== recon-simulation-开始消费 =====");
|
|
|
|
|
+ String value = new String(message.getBody(), StandardCharsets.UTF_8);
|
|
|
|
|
+ // 调用业务层操作
|
|
|
|
|
+ this.executeFunc(value);
|
|
|
|
|
+ return Action.CommitMessage;
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ log.info("===== recon-simulation-消费异常 =====");
|
|
|
|
|
+ e.printStackTrace();
|
|
|
|
|
+ return Action.ReconsumeLater;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 查询处理调优计算结果
|
|
|
|
|
+ */
|
|
|
|
|
+ private void executeFunc(String value) {
|
|
|
|
|
+ ApiResponse<QueryOperationModeDTO> result = simulationPlatformApiClient.queryOperationResult(value);
|
|
|
|
|
+ log.info("查询处理调优计算结果: taskId={}, response={}", value, JSONObject.toJSONString(result));
|
|
|
|
|
+ }
|
|
|
|
|
+}
|