|
@@ -1,53 +1,53 @@
|
|
|
-//package com.fdkankan.scene.listener;
|
|
|
-//
|
|
|
-//import com.fdkankan.scene.service.ISceneUpgradeToV4Service;
|
|
|
-//import com.rabbitmq.client.Channel;
|
|
|
-//import java.nio.charset.StandardCharsets;
|
|
|
-//import lombok.extern.slf4j.Slf4j;
|
|
|
-//import org.springframework.amqp.core.Message;
|
|
|
-//import org.springframework.amqp.rabbit.annotation.Queue;
|
|
|
-//import org.springframework.amqp.rabbit.annotation.RabbitListener;
|
|
|
-//import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-//import org.springframework.beans.factory.annotation.Value;
|
|
|
-//import org.springframework.stereotype.Component;
|
|
|
-//
|
|
|
-///**
|
|
|
-// * <p>
|
|
|
-// * TODO
|
|
|
-// * </p>
|
|
|
-// *
|
|
|
-// * @author dengsixing
|
|
|
-// * @since 2022/4/19
|
|
|
-// **/
|
|
|
-//@Slf4j
|
|
|
-//@Component
|
|
|
-//public class RabbitMqListener {
|
|
|
-//
|
|
|
-// @Value("${queue.scene.upgrade-to-v4}")
|
|
|
-// private String upgradeToV4;
|
|
|
-// @Autowired
|
|
|
-// private ISceneUpgradeToV4Service sceneUpgradeToV4Service;
|
|
|
-//
|
|
|
-// /**
|
|
|
-// * 场景计算前置资源准备处理
|
|
|
-// * @param channel
|
|
|
-// * @param message
|
|
|
-// * @throws Exception
|
|
|
-// */
|
|
|
-// @RabbitListener(
|
|
|
-// queuesToDeclare = @Queue("${queue.scene.upgrade-to-v4}"),
|
|
|
-// concurrency = "${maxThread.scene.upgrade-to-v4}"
|
|
|
-// )
|
|
|
-// public void buildScenePreHandler(Channel channel, Message message) throws Exception {
|
|
|
-// Object correlation = message.getMessageProperties().getHeader("spring_returned_message_correlation");
|
|
|
-// String correlationId = (String) correlation;
|
|
|
-// String msg = new String(message.getBody(), StandardCharsets.UTF_8);
|
|
|
-// log.info("场景升级开始,队列名:{},id:{},消息体:{}", upgradeToV4, correlationId, msg);
|
|
|
-// long sceneProId = Long.parseLong(msg);
|
|
|
-// //迁移数据
|
|
|
-// sceneUpgradeToV4Service.upgrade(sceneProId);
|
|
|
-// log.info("场景升级结束,队列名:{},id:{}", upgradeToV4, correlationId);
|
|
|
-// channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
|
|
|
-// }
|
|
|
-//
|
|
|
-//}
|
|
|
+package com.fdkankan.scene.listener;
|
|
|
+
|
|
|
+import com.fdkankan.scene.service.ISceneUpgradeToV4Service;
|
|
|
+import com.rabbitmq.client.Channel;
|
|
|
+import java.nio.charset.StandardCharsets;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.springframework.amqp.core.Message;
|
|
|
+import org.springframework.amqp.rabbit.annotation.Queue;
|
|
|
+import org.springframework.amqp.rabbit.annotation.RabbitListener;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
+import org.springframework.stereotype.Component;
|
|
|
+
|
|
|
+/**
|
|
|
+ * <p>
|
|
|
+ * TODO
|
|
|
+ * </p>
|
|
|
+ *
|
|
|
+ * @author dengsixing
|
|
|
+ * @since 2022/4/19
|
|
|
+ **/
|
|
|
+@Slf4j
|
|
|
+@Component
|
|
|
+public class RabbitMqListener {
|
|
|
+
|
|
|
+ @Value("${queue.scene.upgrade-to-v4}")
|
|
|
+ private String upgradeToV4;
|
|
|
+ @Autowired
|
|
|
+ private ISceneUpgradeToV4Service sceneUpgradeToV4Service;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 场景计算前置资源准备处理
|
|
|
+ * @param channel
|
|
|
+ * @param message
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+ @RabbitListener(
|
|
|
+ queuesToDeclare = @Queue("${queue.scene.upgrade-to-v4}"),
|
|
|
+ concurrency = "${maxThread.scene.upgrade-to-v4}"
|
|
|
+ )
|
|
|
+ public void buildScenePreHandler(Channel channel, Message message) throws Exception {
|
|
|
+ Object correlation = message.getMessageProperties().getHeader("spring_returned_message_correlation");
|
|
|
+ String correlationId = (String) correlation;
|
|
|
+ String msg = new String(message.getBody(), StandardCharsets.UTF_8);
|
|
|
+ log.info("场景升级开始,队列名:{},id:{},消息体:{}", upgradeToV4, correlationId, msg);
|
|
|
+ long sceneProId = Long.parseLong(msg);
|
|
|
+ //迁移数据
|
|
|
+ sceneUpgradeToV4Service.upgrade(sceneProId);
|
|
|
+ log.info("场景升级结束,队列名:{},id:{}", upgradeToV4, correlationId);
|
|
|
+ channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
|
|
|
+ }
|
|
|
+
|
|
|
+}
|