1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- package com.fdkankan.manage_jp.mq.consumer;
- import com.alibaba.fastjson.JSONObject;
- import com.fdkankan.manage_jp.common.RedisKeyUtil;
- import com.fdkankan.manage_jp.service.impl.SceneCommonService;
- import com.fdkankan.redis.util.RedisUtil;
- import com.rabbitmq.client.Channel;
- 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.stereotype.Component;
- import java.nio.charset.StandardCharsets;
- /**
- * 场景封存解封 mq
- */
- @Slf4j
- @Component
- public class LaserSceneStatusConsumer {
- @Autowired
- SceneCommonService sceneCommonService;
- @Autowired
- RedisUtil redisUtil;
- @RabbitListener(
- queuesToDeclare = @Queue("${queue.scene.laser.status:update-scene-status-ucent}")
- ,concurrency = "1"
- )
- public void consumerQueue(Channel channel, Message message) {
- try {
- String messageId = message.getMessageProperties().getMessageId();
- String msg = new String(message.getBody(), StandardCharsets.UTF_8);
- log.info("update-scene-status-ucent--messageId:{},msg:{}",messageId,msg);
- channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
- JSONObject jsonObject = JSONObject.parseObject(msg);
- String num = jsonObject.getString("num");
- Integer status = jsonObject.getInteger("status");
- if(status == 1){
- sceneCommonService.copyResult(num);
- }
- }catch (Exception e){
- log.info("update-scene-status-ucent----消费失败",e);
- }finally {
- }
- }
- }
|