|
@@ -7,6 +7,8 @@ import com.fdkankan.scene.service.IDownloadTourVideoService;
|
|
|
import com.fdkankan.scene.service.ISceneService;
|
|
|
import com.rabbitmq.client.Channel;
|
|
|
import java.nio.charset.StandardCharsets;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.amqp.core.Message;
|
|
|
import org.springframework.amqp.rabbit.annotation.Queue;
|
|
@@ -82,15 +84,20 @@ public class RabbitMqListener {
|
|
|
* concurrency = "3" 设置消费线程数,每个线程每次只拉取一条消息消费
|
|
|
*/
|
|
|
@RabbitListener(
|
|
|
- queuesToDeclare = @Queue("test_dsx")
|
|
|
+ queuesToDeclare = @Queue("queue.scene.save-scene-orientation:save-scene-orientation")
|
|
|
)
|
|
|
- public void test(Channel channel, Message message) throws Exception {
|
|
|
+ public void saveSceneOrientation(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:{},queue:{},content:{}", messageId, "save-scene-orientation", msg);
|
|
|
+ try {
|
|
|
+ Map<String, String> map = JSON.parseObject(msg, Map.class);
|
|
|
+ sceneService.saveSceneOientation(map);
|
|
|
+ }catch (Exception e){
|
|
|
+ log.error("更新场景方向报错", e);
|
|
|
+ }finally {
|
|
|
+ channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
|
|
|
+ }
|
|
|
log.info("结束消费消息,id:{}", messageId);
|
|
|
}
|
|
|
|