|
@@ -1,77 +1,77 @@
|
|
|
-package com.fdkankan.scene.listener;
|
|
|
-
|
|
|
-import com.alibaba.fastjson.JSON;
|
|
|
-import com.fdkankan.scene.entity.DownloadTourVideo;
|
|
|
-import com.fdkankan.scene.service.IDownloadTourVideoService;
|
|
|
-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.transfer-tour-video}")
|
|
|
- private String downloadTourVideoQueue;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private IDownloadTourVideoService downloadTourVideoService;
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- /**
|
|
|
- * 开启了手动确认模式,如果没有手动确认,消费者不会重试,当服务重启时会再次消费,因为rabbitmq认为你还没有处理完你的业务
|
|
|
- * queuesToDeclare = @Queue("${queue.modeling.modeling-test}"), 如果队列不不存在会自动创建队列
|
|
|
- * concurrency = "3" 设置消费线程数,每个线程每次只拉取一条消息消费
|
|
|
- */
|
|
|
- @RabbitListener(
|
|
|
- queuesToDeclare = @Queue("${queue.scene.transfer-tour-video}")
|
|
|
- )
|
|
|
- public void transferTourVideo(Channel channel, Message message) throws Exception {
|
|
|
- String messageId = message.getMessageProperties().getMessageId();
|
|
|
- String msg = new String(message.getBody(), StandardCharsets.UTF_8);
|
|
|
- log.info("开始消费消息,id:{},queue:{},content:{}", messageId, downloadTourVideoQueue, msg);
|
|
|
- DownloadTourVideo downloadTourVideo = JSON.parseObject(msg, DownloadTourVideo.class);
|
|
|
- downloadTourVideoService.transferTourVideo(downloadTourVideo);
|
|
|
- log.info("deliverTag:" + message.getMessageProperties().getDeliveryTag());
|
|
|
- channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
|
|
|
- log.info("结束消费消息,id:{}", messageId);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 开启了手动确认模式,如果没有手动确认,消费者不会重试,当服务重启时会再次消费,因为rabbitmq认为你还没有处理完你的业务
|
|
|
- * queuesToDeclare = @Queue("${queue.modeling.modeling-test}"), 如果队列不不存在会自动创建队列
|
|
|
- * concurrency = "3" 设置消费线程数,每个线程每次只拉取一条消息消费
|
|
|
- */
|
|
|
- @RabbitListener(
|
|
|
- queuesToDeclare = @Queue("test_dsx")
|
|
|
- )
|
|
|
- public void test(Channel channel, Message message) throws Exception {
|
|
|
- String messageId = message.getMessageProperties().getMessageId();
|
|
|
- String msg = new String(message.getBody(), StandardCharsets.UTF_8);
|
|
|
- channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
|
|
|
- log.info("开始消费消息,id:{},queue:{},content:{}", messageId, "test_dsx", msg);
|
|
|
- Thread.sleep(10000L);
|
|
|
- log.info("deliverTag:" + message.getMessageProperties().getDeliveryTag());
|
|
|
- log.info("结束消费消息,id:{}", messageId);
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-}
|
|
|
+//package com.fdkankan.scene.listener;
|
|
|
+//
|
|
|
+//import com.alibaba.fastjson.JSON;
|
|
|
+//import com.fdkankan.scene.entity.DownloadTourVideo;
|
|
|
+//import com.fdkankan.scene.service.IDownloadTourVideoService;
|
|
|
+//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.transfer-tour-video}")
|
|
|
+// private String downloadTourVideoQueue;
|
|
|
+//
|
|
|
+// @Autowired
|
|
|
+// private IDownloadTourVideoService downloadTourVideoService;
|
|
|
+//
|
|
|
+//
|
|
|
+//
|
|
|
+//
|
|
|
+// /**
|
|
|
+// * 开启了手动确认模式,如果没有手动确认,消费者不会重试,当服务重启时会再次消费,因为rabbitmq认为你还没有处理完你的业务
|
|
|
+// * queuesToDeclare = @Queue("${queue.modeling.modeling-test}"), 如果队列不不存在会自动创建队列
|
|
|
+// * concurrency = "3" 设置消费线程数,每个线程每次只拉取一条消息消费
|
|
|
+// */
|
|
|
+// @RabbitListener(
|
|
|
+// queuesToDeclare = @Queue("${queue.scene.transfer-tour-video}")
|
|
|
+// )
|
|
|
+// public void transferTourVideo(Channel channel, Message message) throws Exception {
|
|
|
+// String messageId = message.getMessageProperties().getMessageId();
|
|
|
+// String msg = new String(message.getBody(), StandardCharsets.UTF_8);
|
|
|
+// log.info("开始消费消息,id:{},queue:{},content:{}", messageId, downloadTourVideoQueue, msg);
|
|
|
+// DownloadTourVideo downloadTourVideo = JSON.parseObject(msg, DownloadTourVideo.class);
|
|
|
+// downloadTourVideoService.transferTourVideo(downloadTourVideo);
|
|
|
+// log.info("deliverTag:" + message.getMessageProperties().getDeliveryTag());
|
|
|
+// channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
|
|
|
+// log.info("结束消费消息,id:{}", messageId);
|
|
|
+// }
|
|
|
+//
|
|
|
+// /**
|
|
|
+// * 开启了手动确认模式,如果没有手动确认,消费者不会重试,当服务重启时会再次消费,因为rabbitmq认为你还没有处理完你的业务
|
|
|
+// * queuesToDeclare = @Queue("${queue.modeling.modeling-test}"), 如果队列不不存在会自动创建队列
|
|
|
+// * concurrency = "3" 设置消费线程数,每个线程每次只拉取一条消息消费
|
|
|
+// */
|
|
|
+// @RabbitListener(
|
|
|
+// queuesToDeclare = @Queue("test_dsx")
|
|
|
+// )
|
|
|
+// public void test(Channel channel, Message message) throws Exception {
|
|
|
+// String messageId = message.getMessageProperties().getMessageId();
|
|
|
+// String msg = new String(message.getBody(), StandardCharsets.UTF_8);
|
|
|
+// channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
|
|
|
+// log.info("开始消费消息,id:{},queue:{},content:{}", messageId, "test_dsx", msg);
|
|
|
+// Thread.sleep(10000L);
|
|
|
+// log.info("deliverTag:" + message.getMessageProperties().getDeliveryTag());
|
|
|
+// log.info("结束消费消息,id:{}", messageId);
|
|
|
+// }
|
|
|
+//
|
|
|
+//
|
|
|
+//
|
|
|
+//
|
|
|
+//}
|