648540858
2024-05-29 764d04b497356ba6bcbb75fd42b51eca750f7223
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/CatalogResponseMessageHandler.java
@@ -1,6 +1,5 @@
package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.response.cmd;
import com.genersoft.iot.vmp.conf.CivilCodeFileConf;
import com.genersoft.iot.vmp.conf.SipConfig;
import com.genersoft.iot.vmp.gb28181.bean.*;
import com.genersoft.iot.vmp.gb28181.session.CatalogDataCatch;
@@ -30,6 +29,7 @@
import java.util.Iterator;
import java.util.List;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.atomic.AtomicBoolean;
/**
 * 目录查询的回复
@@ -38,6 +38,7 @@
public class CatalogResponseMessageHandler extends SIPRequestProcessorParent implements InitializingBean, IMessageHandler {
    private Logger logger = LoggerFactory.getLogger(CatalogResponseMessageHandler.class);
    private final String cmdType = "Catalog";
    @Autowired
@@ -56,10 +57,8 @@
    private ThreadPoolTaskExecutor taskExecutor;
    @Autowired
    private CivilCodeFileConf civilCodeFileConf;
    @Autowired
    private SipConfig sipConfig;
    private AtomicBoolean processing = new AtomicBoolean(false);
    @Override
    public void afterPropertiesSet() throws Exception {
@@ -68,7 +67,6 @@
    @Override
    public void handForDevice(RequestEvent evt, Device device, Element element) {
        boolean isEmpty = taskQueue.isEmpty();
        taskQueue.offer(new HandlerCatchData(evt, device, element));
        // 回复200 OK
        try {
@@ -76,8 +74,8 @@
        } catch (SipException | InvalidArgumentException | ParseException e) {
            logger.error("[命令发送失败] 目录查询回复: {}", e.getMessage());
        }
        // 如果不为空则说明已经开启消息处理
        if (isEmpty) {
        // 已经开启消息处理则跳过
        if (processing.compareAndSet(false, true)) {
            taskExecutor.execute(() -> {
                while (!taskQueue.isEmpty()) {
                    // 全局异常捕获,保证下一条可以得到处理
@@ -116,7 +114,7 @@
                                    if (channelDeviceElement == null) {
                                        continue;
                                    }
                                    DeviceChannel channel = XmlUtil.channelContentHandler(itemDevice, device, null, civilCodeFileConf);
                                    DeviceChannel channel = XmlUtil.channelContentHandler(itemDevice, device, null);
                                    if (channel == null) {
                                        logger.info("[收到目录订阅]:但是解析失败 {}", new String(evt.getRequest().getRawContent()));
                                        continue;
@@ -146,11 +144,12 @@
                            }
                        }
                    }catch (Exception e) {
                    } catch (Exception e) {
                        logger.warn("[收到通道] 发现未处理的异常, \r\n{}", evt.getRequest());
                        logger.error("[收到通道] 异常内容: ", e);
                    }
                }
                processing.set(false);
            });
        }