Browse Source

减少异常抛出

master
jianjun 3 years ago
parent
commit
a3954af108
  1. 6
      epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/mq/listener/OpenDataOrgChangeEventListener.java
  2. 6
      epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/mq/listener/OpenDataPatrolChangeEventListener.java
  3. 6
      epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/mq/listener/OpenDataProjectChangeEventListener.java
  4. 8
      epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/mq/listener/OpenDataStaffChangeEventListener.java
  5. 4
      epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/impl/GridstaffWorkInfoPingyinServiceImpl.java

6
epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/mq/listener/OpenDataOrgChangeEventListener.java

@ -6,7 +6,6 @@ import com.epmet.commons.rocketmq.messages.OrgOrStaffMQMsg;
import com.epmet.commons.tools.constant.StrConstant; import com.epmet.commons.tools.constant.StrConstant;
import com.epmet.commons.tools.distributedlock.DistributedLock; import com.epmet.commons.tools.distributedlock.DistributedLock;
import com.epmet.commons.tools.exception.ExceptionUtils; import com.epmet.commons.tools.exception.ExceptionUtils;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.redis.RedisKeys; import com.epmet.commons.tools.redis.RedisKeys;
import com.epmet.commons.tools.redis.RedisUtils; import com.epmet.commons.tools.redis.RedisUtils;
import com.epmet.commons.tools.utils.SpringContextUtils; import com.epmet.commons.tools.utils.SpringContextUtils;
@ -106,12 +105,9 @@ public class OpenDataOrgChangeEventListener implements MessageListenerConcurrent
SpringContextUtils.getBean(GridInfoPingyinService.class).exractGrid(extractFormDto); SpringContextUtils.getBean(GridInfoPingyinService.class).exractGrid(extractFormDto);
} }
} catch (RenException e) {
// 如果是我们手动抛出的异常,说明在业务可控范围内。目前不需要MQ重试
logger.error("【开放数据事件监听器】-组织信息变更-同步信息到中间库失败:".concat(ExceptionUtils.getErrorStackTrace(e)));
} catch (Exception e) { } catch (Exception e) {
// 不是我们自己抛出的异常,可以让MQ重试 // 不是我们自己抛出的异常,可以让MQ重试
logger.error("【开放数据事件监听器】-组织信息变更-同步信息到中间库失败:".concat(ExceptionUtils.getErrorStackTrace(e))); logger.warn("【开放数据事件监听器】-组织信息变更-同步信息到中间库失败:".concat(ExceptionUtils.getErrorStackTrace(e)));
throw e; throw e;
} finally { } finally {
distributedLock.unLock(lock); distributedLock.unLock(lock);

6
epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/mq/listener/OpenDataPatrolChangeEventListener.java

@ -9,7 +9,6 @@ import com.epmet.commons.tools.distributedlock.DistributedLock;
import com.epmet.commons.tools.exception.EpmetErrorCode; import com.epmet.commons.tools.exception.EpmetErrorCode;
import com.epmet.commons.tools.exception.EpmetException; import com.epmet.commons.tools.exception.EpmetException;
import com.epmet.commons.tools.exception.ExceptionUtils; import com.epmet.commons.tools.exception.ExceptionUtils;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.redis.RedisKeys; import com.epmet.commons.tools.redis.RedisKeys;
import com.epmet.commons.tools.redis.RedisUtils; import com.epmet.commons.tools.redis.RedisUtils;
import com.epmet.commons.tools.utils.SpringContextUtils; import com.epmet.commons.tools.utils.SpringContextUtils;
@ -109,12 +108,9 @@ public class OpenDataPatrolChangeEventListener implements MessageListenerConcurr
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(),"消费失败!"); throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(),"消费失败!");
} }
} catch (RenException e) {
// 如果是我们手动抛出的异常,说明在业务可控范围内。目前不需要MQ重试
logger.error("【开放数据事件监听器】-巡查记录信息变更-失败:".concat(ExceptionUtils.getErrorStackTrace(e)));
} catch (Exception e) { } catch (Exception e) {
// 不是我们自己抛出的异常,可以让MQ重试 // 不是我们自己抛出的异常,可以让MQ重试
logger.error("【开放数据事件监听器】-巡查记录信息变更-失败:".concat(ExceptionUtils.getErrorStackTrace(e))); logger.warn("【开放数据事件监听器】-巡查记录信息变更-失败:".concat(ExceptionUtils.getErrorStackTrace(e)));
throw e; throw e;
} finally { } finally {
distributedLock.unLock(lock); distributedLock.unLock(lock);

6
epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/mq/listener/OpenDataProjectChangeEventListener.java

@ -5,7 +5,6 @@ import com.epmet.commons.rocketmq.constants.MQUserPropertys;
import com.epmet.commons.rocketmq.messages.DisputeProcessMQMsg; import com.epmet.commons.rocketmq.messages.DisputeProcessMQMsg;
import com.epmet.commons.tools.distributedlock.DistributedLock; import com.epmet.commons.tools.distributedlock.DistributedLock;
import com.epmet.commons.tools.exception.ExceptionUtils; import com.epmet.commons.tools.exception.ExceptionUtils;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.redis.RedisKeys; import com.epmet.commons.tools.redis.RedisKeys;
import com.epmet.commons.tools.redis.RedisUtils; import com.epmet.commons.tools.redis.RedisUtils;
import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.utils.ConvertUtils;
@ -77,12 +76,9 @@ public class OpenDataProjectChangeEventListener implements MessageListenerConcur
30L, 30L, TimeUnit.SECONDS); 30L, 30L, TimeUnit.SECONDS);
//SpringContextUtils.getBean(BaseDisputeProcessService.class).getEventinfo(formDTO); //SpringContextUtils.getBean(BaseDisputeProcessService.class).getEventinfo(formDTO);
SpringContextUtils.getBean(EventreportPingyinService.class).getEventInfo(formDTO); SpringContextUtils.getBean(EventreportPingyinService.class).getEventInfo(formDTO);
} catch (RenException e) {
// 如果是我们手动抛出的异常,说明在业务可控范围内。目前不需要MQ重试
logger.error("【开放数据事件监听器】-项目信息变更-上报项目信息失败:".concat(ExceptionUtils.getErrorStackTrace(e)));
} catch (Exception e) { } catch (Exception e) {
// 不是我们自己抛出的异常,可以让MQ重试 // 不是我们自己抛出的异常,可以让MQ重试
logger.error("【开放数据事件监听器】-项目信息变更-上报项目信息失败:".concat(ExceptionUtils.getErrorStackTrace(e))); logger.warn("【开放数据事件监听器】-项目信息变更-上报项目信息失败:".concat(ExceptionUtils.getErrorStackTrace(e)));
throw e; throw e;
} finally { } finally {
distributedLock.unLock(lock); distributedLock.unLock(lock);

8
epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/mq/listener/OpenDataStaffChangeEventListener.java

@ -6,12 +6,10 @@ import com.epmet.commons.rocketmq.messages.OrgOrStaffMQMsg;
import com.epmet.commons.tools.constant.StrConstant; import com.epmet.commons.tools.constant.StrConstant;
import com.epmet.commons.tools.distributedlock.DistributedLock; import com.epmet.commons.tools.distributedlock.DistributedLock;
import com.epmet.commons.tools.exception.ExceptionUtils; import com.epmet.commons.tools.exception.ExceptionUtils;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.redis.RedisKeys; import com.epmet.commons.tools.redis.RedisKeys;
import com.epmet.commons.tools.redis.RedisUtils; import com.epmet.commons.tools.redis.RedisUtils;
import com.epmet.commons.tools.utils.SpringContextUtils; import com.epmet.commons.tools.utils.SpringContextUtils;
import com.epmet.opendata.dto.form.StaffBaseInfoFormDTO; import com.epmet.opendata.dto.form.StaffBaseInfoFormDTO;
import com.epmet.opendata.service.ExUserService;
import com.epmet.opendata.service.GridstaffInfoPingyinService; import com.epmet.opendata.service.GridstaffInfoPingyinService;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyContext; import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyContext;
@ -22,7 +20,6 @@ import org.redisson.api.RLock;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
@ -90,12 +87,9 @@ public class OpenDataStaffChangeEventListener implements MessageListenerConcurre
SpringContextUtils.getBean(ExUserService.class).getStaffBaseInfo(dto);*/ SpringContextUtils.getBean(ExUserService.class).getStaffBaseInfo(dto);*/
dto.setStaffIdList(obj.getStaffIdList()); dto.setStaffIdList(obj.getStaffIdList());
SpringContextUtils.getBean(GridstaffInfoPingyinService.class).getStaffBaseInfo(dto); SpringContextUtils.getBean(GridstaffInfoPingyinService.class).getStaffBaseInfo(dto);
} catch (RenException e) {
// 如果是我们手动抛出的异常,说明在业务可控范围内。目前不需要MQ重试
logger.error("【开放数据事件监听器】-工作人员信息变更-初始化客户组织失败:".concat(ExceptionUtils.getErrorStackTrace(e)));
} catch (Exception e) { } catch (Exception e) {
// 不是我们自己抛出的异常,可以让MQ重试 // 不是我们自己抛出的异常,可以让MQ重试
logger.error("【开放数据事件监听器】-工作人员信息变更-初始化客户组织失败:".concat(ExceptionUtils.getErrorStackTrace(e))); logger.warn("【开放数据事件监听器】-工作人员信息变更-初始化客户组织失败:".concat(ExceptionUtils.getErrorStackTrace(e)));
throw e; throw e;
} finally { } finally {
distributedLock.unLock(lock); distributedLock.unLock(lock);

4
epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/impl/GridstaffWorkInfoPingyinServiceImpl.java

@ -73,6 +73,10 @@ public class GridstaffWorkInfoPingyinServiceImpl extends BaseServiceImpl<Gridsta
throw new EpmetException(EpmetErrorCode.SERVER_ERROR.getCode()); throw new EpmetException(EpmetErrorCode.SERVER_ERROR.getCode());
} }
data.forEach(d -> { data.forEach(d -> {
if (StringUtils.isBlank(d.getGridId())){
log.warn("data is null string:{}",JSON.toJSONString(d));
return;
}
GridInfoCache gridInfo = CustomerOrgRedis.getGridInfo(d.getGridId()); GridInfoCache gridInfo = CustomerOrgRedis.getGridInfo(d.getGridId());
if (null == gridInfo) { if (null == gridInfo) {
log.warn("未查询到网格信息:" + d.getGridId()); log.warn("未查询到网格信息:" + d.getGridId());

Loading…
Cancel
Save