From a3d871022c68053ed5fa2c3d213fca7ec4d2136d Mon Sep 17 00:00:00 2001
From: 648540858 <648540858@qq.com>
Date: 星期五, 21 七月 2023 15:13:20 +0800
Subject: [PATCH] 修复空指针异常
---
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/NotifyRequestProcessor.java | 34 ++++++++++++++++++++++++++++------
1 files changed, 28 insertions(+), 6 deletions(-)
diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/NotifyRequestProcessor.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/NotifyRequestProcessor.java
index a0038ca..f75c8ba 100644
--- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/NotifyRequestProcessor.java
+++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/NotifyRequestProcessor.java
@@ -1,6 +1,7 @@
package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl;
import com.alibaba.fastjson2.JSONObject;
+import com.genersoft.iot.vmp.conf.CivilCodeFileConf;
import com.genersoft.iot.vmp.conf.SipConfig;
import com.genersoft.iot.vmp.conf.UserSetting;
import com.genersoft.iot.vmp.gb28181.bean.*;
@@ -76,11 +77,19 @@
@Autowired
private IDeviceChannelService deviceChannelService;
+ @Autowired
+ private NotifyRequestForCatalogProcessor notifyRequestForCatalogProcessor;
+
+ @Autowired
+ private CivilCodeFileConf civilCodeFileConf;
+
private ConcurrentLinkedQueue<HandlerCatchData> taskQueue = new ConcurrentLinkedQueue<>();
@Qualifier("taskExecutor")
@Autowired
private ThreadPoolTaskExecutor taskExecutor;
+
+ private int maxQueueCount = 30000;
@Override
public void afterPropertiesSet() throws Exception {
@@ -91,17 +100,29 @@
@Override
public void process(RequestEvent evt) {
try {
- responseAck((SIPRequest) evt.getRequest(), Response.OK, null, null);
+
+ if (taskQueue.size() >= userSetting.getMaxNotifyCountQueue()) {
+ responseAck((SIPRequest) evt.getRequest(), Response.BUSY_HERE, null, null);
+ logger.error("[notify] 寰呭鐞嗘秷鎭槦鍒楀凡婊� {}锛岃繑鍥�486 BUSY_HERE锛屾秷鎭笉鍋氬鐞�", userSetting.getMaxNotifyCountQueue());
+ return;
+ }else {
+ responseAck((SIPRequest) evt.getRequest(), Response.OK, null, null);
+ }
+
}catch (SipException | InvalidArgumentException | ParseException e) {
logger.error("鏈鐞嗙殑寮傚父 ", e);
}
boolean runed = !taskQueue.isEmpty();
+ logger.info("[notify] 寰呭鐞嗘秷鎭暟閲忥細 {}", taskQueue.size());
taskQueue.offer(new HandlerCatchData(evt, null, null));
if (!runed) {
taskExecutor.execute(()-> {
while (!taskQueue.isEmpty()) {
try {
HandlerCatchData take = taskQueue.poll();
+ if (take == null) {
+ continue;
+ }
Element rootElement = getRootElement(take.getEvt());
if (rootElement == null) {
logger.error("澶勭悊NOTIFY娑堟伅鏃舵湭鑾峰彇鍒版秷鎭綋,{}", take.getEvt().getRequest());
@@ -111,7 +132,8 @@
if (CmdType.CATALOG.equals(cmd)) {
logger.info("鎺ユ敹鍒癈atalog閫氱煡");
- processNotifyCatalogList(take.getEvt());
+// processNotifyCatalogList(take.getEvt());
+ notifyRequestForCatalogProcessor.process(take.getEvt());
} else if (CmdType.ALARM.equals(cmd)) {
logger.info("鎺ユ敹鍒癆larm閫氱煡");
processNotifyAlarm(take.getEvt());
@@ -131,7 +153,7 @@
/**
* 澶勭悊MobilePosition绉诲姩浣嶇疆Notify
- *
+ *
* @param evt
*/
private void processNotifyMobilePosition(RequestEvent evt) {
@@ -235,7 +257,7 @@
/***
* 澶勭悊alarm璁惧鎶ヨNotify
- *
+ *
* @param evt
*/
private void processNotifyAlarm(RequestEvent evt) {
@@ -345,7 +367,7 @@
/***
* 澶勭悊catalog璁惧鐩綍鍒楄〃Notify
- *
+ *
* @param evt
*/
private void processNotifyCatalogList(RequestEvent evt) {
@@ -385,7 +407,7 @@
}else {
event = eventElement.getText().toUpperCase();
}
- DeviceChannel channel = XmlUtil.channelContentHander(itemDevice, device, event);
+ DeviceChannel channel = XmlUtil.channelContentHandler(itemDevice, device, event, civilCodeFileConf);
channel.setDeviceId(device.getDeviceId());
logger.info("[鏀跺埌鐩綍璁㈤槄]锛歿}/{}", device.getDeviceId(), channel.getChannelId());
switch (event) {
--
Gitblit v1.8.0