| //package com.xzx.gc.system.service;  | 
| //  | 
| //import cn.hutool.core.collection.CollUtil;  | 
| //import cn.hutool.core.exceptions.ExceptionUtil;  | 
| //import cn.hutool.json.JSONUtil;  | 
| //import com.xzx.gc.common.constant.Constants;  | 
| //import com.xzx.gc.common.dto.MessageDto;  | 
| //import com.xzx.gc.common.utils.BusinessUtil;  | 
| //import com.xzx.gc.common.utils.RedisUtil;  | 
| //import com.xzx.gc.common.utils.SpringUtil;  | 
| //import lombok.extern.slf4j.Slf4j;  | 
| //import org.springframework.amqp.core.AmqpTemplate;  | 
| //import org.springframework.amqp.core.Message;  | 
| //import org.springframework.amqp.core.MessageBuilder;  | 
| //import org.springframework.amqp.core.MessageProperties;  | 
| //import org.springframework.beans.factory.annotation.Autowired;  | 
| //import org.springframework.scheduling.annotation.Async;  | 
| //import org.springframework.scheduling.annotation.Scheduled;  | 
| //import org.springframework.stereotype.Service;  | 
| //import org.springframework.transaction.annotation.Transactional;  | 
| //  | 
| //import java.util.List;  | 
| //  | 
| //@Service  | 
| //@Transactional  | 
| //@Slf4j  | 
| //public class QueueService {  | 
| //  | 
| //    @Autowired  | 
| //    private RedisUtil redisUtil;  | 
| //  | 
| //    @Autowired  | 
| //    private AmqpTemplate amqpTemplate;  | 
| //  | 
| //    @Autowired  | 
| //    private BusinessUtil businessUtil;  | 
| //  | 
| //    @Scheduled(cron = "${cron.errorQueue}")  | 
| //    @Async  | 
| //    public void syncQueue() {  | 
| //        log.trace("********定时同步错误队列*********");  | 
| //        if(!SpringUtil.isCloud()) {  | 
| //            List<String> queueList = redisUtil.lrange(Constants.REDIS_LOG_KEY + "err:queue", 0, -1);  | 
| //            if (CollUtil.isNotEmpty(queueList)) {  | 
| //                for (String queue : queueList) {  | 
| //                    MessageDto messageDto = JSONUtil.toBean(queue, MessageDto.class);  | 
| //                    String uuid = messageDto.getUuid();  | 
| //                    Message message = MessageBuilder.withBody(messageDto.getJson().getBytes())  | 
| //                            .setContentType(MessageProperties.CONTENT_TYPE_JSON).setContentEncoding("utf-8")  | 
| //                            .setMessageId(uuid).build();  | 
| //                    String queueName = messageDto.getQueueName();  | 
| //                    String errMsg = "";  | 
| //                    try {  | 
| //                        redisUtil.set(Constants.REDIS_LOG_KEY + uuid, queueName);  | 
| //                        amqpTemplate.convertAndSend(queueName, message);  | 
| //                        //删除元素  | 
| //                        redisUtil.lremAll(Constants.REDIS_LOG_KEY + "err:queue", queue);  | 
| //                    } catch (Exception e) {  | 
| //                        redisUtil.del(Constants.REDIS_LOG_KEY + uuid);  | 
| //                        log.error("定时同步错误队列失败");  | 
| //                        errMsg = ExceptionUtil.getMessage(e);  | 
| //                    } finally {  | 
| //                        businessUtil.queueConsole(queueName, uuid, errMsg);  | 
| //                    }  | 
| //                }  | 
| //            }  | 
| //        }  | 
| //        log.trace("********定时同步错误队列结束*********");  | 
| //    }  | 
| //}  |