liusheng
2024-06-06 ef81a5cbfbb98974ed1ba54d0e47b7e74a9b96b9
ruoyi-admin/src/main/java/com/ruoyi/web/component/RabbitMqReceiver.java
@@ -34,6 +34,7 @@
import java.util.Map;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
@Slf4j
@Component//监听此队列
@@ -107,13 +108,12 @@
     */
    @RabbitListener(queues = "task_queue", concurrency = "50")
    public void phoneVisit(String content, Message message, Channel channel) throws IOException {
        log.error("消息进来了--------------");
        System.out.println("消息进来了----------------");
        IvrTaskcallMQ ivrTaskcallMQ = null;
        try {
            IvrTaskcallMQ ivrTaskcallMQ = null;
            ObjectMapper mapper = new ObjectMapper();
            try {
                if (!content.contains("{")) {
                if (!content.startsWith("{")) {
                    ivrTaskcallMQ = mapper.readValue("{" + content + "}", IvrTaskcallMQ.class);
                } else {
                    ivrTaskcallMQ = mapper.readValue(content, IvrTaskcallMQ.class);
@@ -171,7 +171,7 @@
                            String patid = rsaPublicKeyExample.encryptedData(ivrTaskSingle.getPatid().toString(), pub_key);
                            SendMagParam sendMagParam = new SendMagParam();
                            sendMagParam.setType("4");
                            sendMagParam.setUrl("192.168.2.10:8099/followvisit/particty?param1=" + taskId + "&param2=" + patid);
                            sendMagParam.setUrl(req_path + "/followvisit/particty?param1=" + taskId + "&param2=" + patid);
                            sendService.sendMsg(sendMagParam);
                        }
                    } else if (descByCode.equals("公众号")) {
@@ -197,6 +197,15 @@
                }
            }
        } catch (Exception e) {
            Integer integer = redisCache.getCacheObject(ivrTaskcallMQ.getTaskid().toString());
            if (integer != null && integer == 2) {
                channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
            } else if (integer == null) {
                redisCache.setCacheObject(ivrTaskcallMQ.getTaskid().toString(), 1, 120, TimeUnit.MINUTES);
            } else {
                redisCache.setCacheObject(ivrTaskcallMQ.getTaskid().toString(), integer + 1, 120, TimeUnit.MINUTES);
            }
            log.error("============消费失败,尝试消息补发再次消费!==============");
            log.error(e.getMessage());
            channel.basicReject(message.getMessageProperties().getDeliveryTag(), true);