diff --git a/src/main/java/com/eactive/eai/rms/data/entity/onl/djb/inflow/InflowTokenInsufficient.java b/src/main/java/com/eactive/eai/rms/data/entity/onl/djb/inflow/InflowTokenInsufficient.java deleted file mode 100644 index 64108f8..0000000 --- a/src/main/java/com/eactive/eai/rms/data/entity/onl/djb/inflow/InflowTokenInsufficient.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.eactive.eai.rms.data.entity.onl.djb.inflow; - -public interface InflowTokenInsufficient { - String getEaisvcname(); - String getEaisvcdesc(); - Long getCnt(); -} \ No newline at end of file diff --git a/src/main/java/com/eactive/eai/rms/ext/djb/inflow/InflowTokenRepository.java b/src/main/java/com/eactive/eai/rms/ext/djb/inflow/InflowTokenRepository.java index d98c99c..3b76428 100644 --- a/src/main/java/com/eactive/eai/rms/ext/djb/inflow/InflowTokenRepository.java +++ b/src/main/java/com/eactive/eai/rms/ext/djb/inflow/InflowTokenRepository.java @@ -1,21 +1,16 @@ package com.eactive.eai.rms.ext.djb.inflow; -import java.util.List; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; import com.eactive.eai.data.jpa.BaseRepository; -import com.eactive.eai.rms.data.entity.onl.djb.inflow.InflowTokenInsufficient; import com.eactive.eai.rms.data.entity.onl.djb.inflow.InflowTokenInsufficientLog; import com.eactive.eai.rms.data.entity.onl.djb.inflow.InflowTokenInsufficientLogId; public interface InflowTokenRepository extends BaseRepository { @Query(nativeQuery = true, value = - " SELECT EAISVCNAME" + - " , (SELECT EAISVCDESC FROM TSEAIHE01 WHERE A.EAISVCNAME = EAISVCNAME) AS EAISVCDESC" + - " , COUNT(*) AS CNT" + - " FROM TSEAIFR11 A" + - " WHERE MSGDPSTYMS >= TO_CHAR(SYSTIMESTAMP - NUMTODSINTERVAL(:rangeMinute, 'MINUTE'), 'YYYYMMDDHH24MISSFF3')" + - " GROUP BY EAISVCNAME") - List countTokenInsufficient(@Param("rangeMinute") long rangeMinute); -} \ No newline at end of file + " SELECT COUNT(*)" + + " FROM TSEAIFR11" + + " WHERE MSGDPSTYMS >= TO_CHAR(SYSTIMESTAMP - NUMTODSINTERVAL(:rangeMinute, 'MINUTE'), 'YYYYMMDDHH24MISSFF3')") + long countTokenInsufficient(@Param("rangeMinute") long rangeMinute); +} diff --git a/src/main/java/com/eactive/eai/rms/ext/djb/inflow/InflowTokenService.java b/src/main/java/com/eactive/eai/rms/ext/djb/inflow/InflowTokenService.java index 1f945cd..2297511 100644 --- a/src/main/java/com/eactive/eai/rms/ext/djb/inflow/InflowTokenService.java +++ b/src/main/java/com/eactive/eai/rms/ext/djb/inflow/InflowTokenService.java @@ -1,7 +1,6 @@ package com.eactive.eai.rms.ext.djb.inflow; import java.util.HashMap; -import java.util.List; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -11,7 +10,6 @@ import org.springframework.transaction.annotation.Transactional; import com.eactive.apim.portal.template.entity.MessageCode; import com.eactive.eai.rms.common.context.MonitoringContext; -import com.eactive.eai.rms.data.entity.onl.djb.inflow.InflowTokenInsufficient; import com.eactive.eai.rms.ext.djb.ums.UmsManager; @@ -23,25 +21,29 @@ public class InflowTokenService { @Autowired private InflowTokenRepository inflowTokenRepository; - + @Autowired private MonitoringContext monitoringContext; - + @Autowired - private UmsManager ums; + private UmsManager ums; public void checkRecentFails(long rangeMinute) { - if (monitoringContext.getBooleanProperty(MonitoringContext.DJB_UMS_MESSENGER_APIMONITOR_ENABLED, true)) { - List rows = inflowTokenRepository.countTokenInsufficient(rangeMinute); - - for (InflowTokenInsufficient info : rows) { - log.debug("유량제어 토큰 획득 실패: {}-{} 최근 {}분 동안 {}건", info.getEaisvcname(), info.getEaisvcdesc(), rangeMinute, info.getCnt()); - String message = "유량제어 토큰 획득 실패가 발생하였습니다 \n" + info.getEaisvcname(); - - HashMap params = new HashMap(); - params.put("message", message); - ums.sendMessenger("api-monitor", MessageCode.INFLOW_TOKEN_FAILED, params); - } + if (!monitoringContext.getBooleanProperty(MonitoringContext.DJB_UMS_MESSENGER_APIMONITOR_ENABLED, true)) { + return; } + + long failCount = inflowTokenRepository.countTokenInsufficient(rangeMinute); + if (failCount <= 0) { + return; + } + + log.debug("유량제어 토큰 획득 실패: 최근 {}분 동안 {}건", rangeMinute, failCount); + + String message = "유량제어 토큰 획득 실패가 발생하였습니다\n최근 " + rangeMinute + "분 동안 " + failCount + "건"; + + HashMap params = new HashMap(); + params.put("message", message); + ums.sendMessenger("api-monitor", MessageCode.INFLOW_TOKEN_FAILED, params); } }