Merge branch 'devs/ums' into jenkins_with_weblogic

This commit is contained in:
Rinjae
2025-11-05 12:26:12 +09:00
5 changed files with 164 additions and 42 deletions
+39
View File
@@ -0,0 +1,39 @@
# 광주은행용 Property 설정
## 참고 Class
- com.eactive.ext.kjb.common.KjbProperty
## Monitoring
### UMS 관련 (kjb.ums)
- 실제 광주은행 내에서는 UMS 는 SMS/LMS/알림톡 등 만 담당.
- 이메일 발송은 별도 시스템이 있음 (JSON 형식의 파일로 EAI 배치 이용 연계)
- kjb.eai_batch.url
- 개발 : http://172.31.32.111:10230/BATAppWeb/EaiBatCall
- 검증 : http://172.31.33.111:10430/BATAppWeb/EaiBatCall
- 운영 : http://172.21.1.40:10860/BATAppWeb/EaiBatCall
- kjb.ums.host_url
- 개발 : http://172.31.35.144:9021
- 운영 :
- kjb.ums.api_key
- 개발 API KEY(192.168.240.176) : `7cca6d58-e4f7-474d-9edd-525806bc99ff`
- 운영 API KEY(192.168.132.77 / 192.168.132.78 / 192.168.157.77 ) : `6a40a69f-5614-485b-8d0f-6fb2e2e51bfe`
- kjb.ums.eai_batch.send_dir : /Data/eapim/portal/sendmail/snd
- kjb.ums.eai_batch.backup_dir : /Data/eapim/portal/sendmail/bak
## 개발 Property
| Key | 이름 | Value | 분류 | |
| ------------------------------------ | ------------------------ | ----------------------------------------------- | --- | --- |
| kjb.eai_batch.url | EAI 배치 호출 주소 | http://172.31.32.111:10230/BATAppWeb/EaiBatCall | 이메일 | |
| kjb.ums.eai_batch.connection_timeout | EAI 배치 커넥션 타임아웃(seconds) | 5 | 이메일 | |
| kjb.ums.eai_batch.response_timeout | EAI 배치 응답 타임아웃(seconds) | 10 | 이메일 | |
| kjb.ums.eai_batch.send_dir | EAI 배치 발송용 디렉토리 | /Data/eapim/portal/sendmail/snd | 이메일 | |
| kjb.ums.eai_batch.backup_dir | EAI 배치 발송 이후 백업 디렉토리 | /Data/eapim/portal/sendmail/bak | 이메일 | |
| kjb.ums.eai_batch.interface_id | 고객이메일발송용 EAI 배치 인터페이스 | UAGFF00001UIE | 알림톡 | |
| kjb.ums.host_url | UMS 호출 주소 | http://172.31.35.144:9021 | 알림톡 | |
| kjb.ums.api_key | UMS API Key | 7cca6d58-e4f7-474d-9edd-525806bc99ff | 알림톡 | |
| kjb.ums.connection_timeout | UMS 커넥션 타임아웃(seconds) | 5 | 알림톡 | |
| kjb.ums.response_timeout | UMS 응답 타임아웃(seconds) | 10 | 알림톡 | |
-
@@ -2,6 +2,7 @@ package com.eactive.eai.rms.onl.common.service;
import com.eactive.eai.rms.onl.common.service.ums.UmsDispatchService; import com.eactive.eai.rms.onl.common.service.ums.UmsDispatchService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.quartz.Job; import org.quartz.Job;
import org.quartz.JobExecutionContext; import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException; import org.quartz.JobExecutionException;
@@ -28,6 +29,25 @@ public class UmsDispatchJob implements Job {
@Override @Override
public void execute(JobExecutionContext context) throws JobExecutionException { public void execute(JobExecutionContext context) throws JobExecutionException {
log.info("Starting Message Dispatch Job..."); log.info("Starting Message Dispatch Job...");
// inst.Name 이 지정된 경우 해당 인스턴스에서만 동작
String jobInstName = context.getJobDetail().getJobDataMap().getString("inst.Name");
if (StringUtils.isNotEmpty(jobInstName)) {
log.debug("Job 실행 인스턴스 명이 지정되어 있음 - {}", jobInstName);
jobInstName = jobInstName.trim();
String instanceName = System.getProperty("inst.Name");
if (StringUtils.isNotEmpty(instanceName)) {
log.debug("현재 인스턴스 명 : {}", instanceName);
instanceName = instanceName.trim();
if (!jobInstName.equalsIgnoreCase(instanceName)) {
log.debug("Job 인스턴스명과 현재 인스턴스명이 다름. 종료 처리");
return;
}
}
}
try { try {
umsDispatchService.processMessages(); umsDispatchService.processMessages();
} catch (Exception e) { } catch (Exception e) {
@@ -1,9 +1,13 @@
package com.eactive.eai.rms.onl.common.service.ums; package com.eactive.eai.rms.onl.common.service.ums;
import com.eactive.apim.portal.template.entity.MessageRequest; import com.eactive.apim.portal.template.entity.MessageRequest;
import com.eactive.eai.rms.data.entity.man.monitoringProperty.service.MonitoringPropertyService;
import edu.emory.mathcs.backport.java.util.Collections; import com.eactive.ext.kjb.common.KjbProperty;
import com.eactive.ext.kjb.safedb.KjbSafedbWrapper;
import com.eactive.ext.kjb.ums.KjbEmailService;
import com.eactive.ext.kjb.ums.KjbUmsService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.NotImplementedException;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@@ -15,15 +19,17 @@ import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext; import javax.persistence.PersistenceContext;
import java.io.IOException; import java.io.IOException;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.concurrent.*; import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
@Slf4j @Slf4j
@Service @Service
@Transactional(transactionManager = "transactionManagerForEMS") @Transactional(transactionManager = "transactionManagerForEMS")
public class UmsDispatchService { public class UmsDispatchService {
public static final String PROP_GORUP_ID = "Monitoring";
private final ThreadPoolExecutor executorService; private final ThreadPoolExecutor executorService;
private final TransactionTemplate transactionTemplate; private final TransactionTemplate transactionTemplate;
@@ -36,15 +42,23 @@ public class UmsDispatchService {
@PersistenceContext(unitName = "entityManagerFactoryForEMS") @PersistenceContext(unitName = "entityManagerFactoryForEMS")
private EntityManager entityManager; private EntityManager entityManager;
@Autowired // private final KjbEmailService kjbEmailService;
private UmsSender umsSender; // private final KjbSafedbWrapper kjbSafedbWrapper;
// private final MonitoringPropertyService monitoringPropertyService;
private final KjbUmsService kjbUmsService;
@Autowired
private StandardMessageFactory messageFactory;
@Autowired @Autowired
public UmsDispatchService( public UmsDispatchService(
@Qualifier("transactionManagerForEMS") PlatformTransactionManager transactionManager) { @Qualifier("transactionManagerForEMS") PlatformTransactionManager transactionManager,
// KjbSafedbWrapper kjbSafedbWrapper,
MonitoringPropertyService monitoringPropertyService
) {
// this.kjbEmailService = kjbEmailService;
// this.kjbSafedbWrapper = kjbSafedbWrapper;
// this.monitoringPropertyService = monitoringPropertyService;
this.executorService = new ThreadPoolExecutor( this.executorService = new ThreadPoolExecutor(
CORE_POOL_SIZE, CORE_POOL_SIZE,
MAX_POOL_SIZE, MAX_POOL_SIZE,
@@ -56,6 +70,17 @@ public class UmsDispatchService {
this.transactionTemplate = new TransactionTemplate(transactionManager); this.transactionTemplate = new TransactionTemplate(transactionManager);
log.debug("UmsDispatchService initialized with thread pool - core: {}, max: {}, queue: {}", log.debug("UmsDispatchService initialized with thread pool - core: {}, max: {}, queue: {}",
CORE_POOL_SIZE, MAX_POOL_SIZE, QUEUE_CAPACITY); CORE_POOL_SIZE, MAX_POOL_SIZE, QUEUE_CAPACITY);
KjbProperty prop = new KjbProperty();
prop.setEaiBatchUrl(monitoringPropertyService.getPrpty2ValById(PROP_GORUP_ID, "kjb.ums.eai_batch.url"));
prop.setUmsEaiBatchSendDir(monitoringPropertyService.getPrpty2ValById(PROP_GORUP_ID, "kjb.ums.eai_batch.send_dir"));
prop.setUmsEaiBatchBackupDir(monitoringPropertyService.getPrpty2ValById(PROP_GORUP_ID, "kjb.ums.eai_batch.backup_dir"));
prop.setUmsEaiBatchInterfaceId(monitoringPropertyService.getPrpty2ValById(PROP_GORUP_ID, "kjb.ums.eai_batch.interface_id"));
prop.setUmsHostUrl(monitoringPropertyService.getPrpty2ValById(PROP_GORUP_ID, "kjb.ums.host_url"));
prop.setUmsApiKey(monitoringPropertyService.getPrpty2ValById(PROP_GORUP_ID, "kjb.ums.api_key"));
this.kjbUmsService = new KjbUmsService(prop);
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@@ -110,7 +135,18 @@ public class UmsDispatchService {
try { try {
transactionTemplate.execute(status -> { transactionTemplate.execute(status -> {
try { try {
processMessage(message); // 광주은행에서는 사용하지 않는 메소드
// processMessage(message);
if (KjbUmsService.isAllowChannel(message)) {
kjbUmsService.send(message);
}
if (KjbEmailService.isAllowChannel(message)) {
throw new NotImplementedException();
// kjbEmailService.sendEmail(message);
}
return null; return null;
} catch (Exception e) { } catch (Exception e) {
log.error("Failed to process message: {} - Error: {}", log.error("Failed to process message: {} - Error: {}",
@@ -127,21 +163,27 @@ public class UmsDispatchService {
}); });
} }
public void processMessage(MessageRequest message) throws IOException { /**
try { * kbank 방식으로 광주은행에서는 사용하지 않음
String standardMessage = messageFactory.createMessage(message); * @param message
log.debug("Processing message ID: {} - Type: {}", message.getId(), message.getMessageType()); * @throws IOException
*/
umsSender.sendMessage(standardMessage); // @Deprecated
updateMessageStatus(message, "SENT"); // public void processMessage(MessageRequest message) throws IOException {
log.debug("Successfully processed and sent message ID: {}", message.getId()); // try {
} catch (Exception e) { // String standardMessage = messageFactory.createMessage(message);
log.error("Message processing failed for ID: {} - Error: {}", // log.debug("Processing message ID: {} - Type: {}", message.getId(), message.getMessageType());
message.getId(), e.getMessage(), e); //
updateMessageStatus(message, "FAILED"); // umsSender.sendMessage(standardMessage);
throw e; // updateMessageStatus(message, "SENT");
} // log.debug("Successfully processed and sent message ID: {}", message.getId());
} // } catch (Exception e) {
// log.error("Message processing failed for ID: {} - Error: {}",
// message.getId(), e.getMessage(), e);
// updateMessageStatus(message, "FAILED");
// throw e;
// }
// }
public void updateMessageStatus(MessageRequest message, String status) { public void updateMessageStatus(MessageRequest message, String status) {
message.setRequestStatus(status); message.setRequestStatus(status);
@@ -16,8 +16,12 @@ import org.springframework.stereotype.Component;
import java.io.IOException; import java.io.IOException;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
/**
* 25.11.05 - 광주은행 미사용 클래스
*/
@Slf4j @Slf4j
@Component @Component
@Deprecated
public class UmsSender { public class UmsSender {
private final MonitoringPropertyService monitoringPropertyService; private final MonitoringPropertyService monitoringPropertyService;
@@ -1,5 +1,6 @@
package com.eactive.ext.kjb.ums; package com.eactive.ext.kjb.ums;
import com.eactive.apim.portal.template.entity.MessageCode;
import com.eactive.apim.portal.template.entity.MessageRequest; import com.eactive.apim.portal.template.entity.MessageRequest;
import com.eactive.eai.rms.common.base.BaseService; import com.eactive.eai.rms.common.base.BaseService;
import com.eactive.eai.rms.data.entity.man.monitoringProperty.service.MonitoringPropertyService; import com.eactive.eai.rms.data.entity.man.monitoringProperty.service.MonitoringPropertyService;
@@ -22,7 +23,9 @@ import java.util.Arrays;
@Service @Service
@Transactional(transactionManager = "transactionManagerForEMS") @Transactional(transactionManager = "transactionManagerForEMS")
@Slf4j @Slf4j
public class KjbUmsService extends BaseService { public class KjbEmailService extends BaseService {
public final static int[] ALLOW_CHANNELS = { MessageCode.Channels.EMAIL.getValue() };
public static final String PROP_GORUP_ID = "Monitoring"; public static final String PROP_GORUP_ID = "Monitoring";
public static final String PROP_EAI_BATCH_URL = "kjb.ums.eai_batch.url"; public static final String PROP_EAI_BATCH_URL = "kjb.ums.eai_batch.url";
public static final String PROP_EAI_BATCH_SEND_DIR = "kjb.ums.eai_batch.send_dir"; public static final String PROP_EAI_BATCH_SEND_DIR = "kjb.ums.eai_batch.send_dir";
@@ -34,18 +37,32 @@ public class KjbUmsService extends BaseService {
@Autowired @Autowired
public KjbUmsService(KjbSafedbWrapper kjbSafedbWrapper, public KjbEmailService(MonitoringPropertyService monitoringPropertyService) {
MonitoringPropertyService monitoringPropertyService) { this.kjbSafedbWrapper = KjbSafedbWrapper.getInstance();
this.kjbSafedbWrapper = kjbSafedbWrapper;
KjbProperty prop = new KjbProperty(); KjbProperty prop = new KjbProperty();
prop.setEaiBatchUrl(monitoringPropertyService.getPropertyValue(PROP_GORUP_ID, PROP_EAI_BATCH_URL, "")); prop.setEaiBatchUrl(monitoringPropertyService.getPrpty2ValById(PROP_GORUP_ID, PROP_EAI_BATCH_URL));
prop.setEaiBatchSendDir(monitoringPropertyService.getPropertyValue(PROP_GORUP_ID, PROP_EAI_BATCH_SEND_DIR, "/Data/files/send")); prop.setUmsEaiBatchSendDir(monitoringPropertyService.getPrpty2ValById(PROP_GORUP_ID, PROP_EAI_BATCH_SEND_DIR));
prop.setUmsEaiBatchBackupDir(monitoringPropertyService.getPrpty2ValById(PROP_GORUP_ID, "kjb.ums.eai_batch.backup_dir"));
prop.setUmsEaiBatchInterfaceId(monitoringPropertyService.getPrpty2ValById(PROP_GORUP_ID, "kjb.ums.eai_batch.interface_id"));
prop.setUmsHostUrl(monitoringPropertyService.getPrpty2ValById(PROP_GORUP_ID, "kjb.ums.host_url"));
prop.setUmsApiKey(monitoringPropertyService.getPrpty2ValById(PROP_GORUP_ID, "kjb.ums.api_key"));
this.prop = prop; this.prop = prop;
} }
public KjbUmsService(KjbSafedbWrapper kjbSafedbWrapper,
public static boolean isAllowChannel(MessageRequest message) {
for (int channel : ALLOW_CHANNELS) {
if ((message.getMessageCode().getChannels() & channel) == channel) {
return true;
}
}
return false;
}
public KjbEmailService(KjbSafedbWrapper kjbSafedbWrapper,
KjbProperty property) { KjbProperty property) {
this.kjbSafedbWrapper = kjbSafedbWrapper; this.kjbSafedbWrapper = kjbSafedbWrapper;
this.prop = property; this.prop = property;
@@ -60,34 +77,34 @@ public class KjbUmsService extends BaseService {
} }
log.info("EAI Batch URL: {}", prop.getEaiBatchUrl()); log.info("EAI Batch URL: {}", prop.getEaiBatchUrl());
log.info("EAI Batch Send Dir: {}", prop.getEaiBatchSendDir()); log.info("EAI Batch Send Dir: {}", prop.getUmsEaiBatchSendDir());
// 디렉토리 검사(쓰기 권한 포함) // 디렉토리 검사(쓰기 권한 포함)
Path sendDirPath = Paths.get(prop.getEaiBatchSendDir()); Path sendDirPath = Paths.get(prop.getUmsEaiBatchSendDir());
if (!sendDirPath.toFile().exists()) { if (!sendDirPath.toFile().exists()) {
// 생성 시도 // 생성 시도
boolean created = sendDirPath.toFile().mkdirs(); boolean created = sendDirPath.toFile().mkdirs();
if (!created) { if (!created) {
log.error("EAI_BATCH_SEND_DIR 디렉토리를 생성할 수 없음: {}", prop.getEaiBatchSendDir()); log.error("EAI_BATCH_SEND_DIR 디렉토리를 생성할 수 없음: {}", prop.getUmsEaiBatchSendDir());
throw new IllegalStateException("EAI_BATCH_SEND_DIR 디렉토리를 생성할 수 없음: " + prop.getEaiBatchSendDir()); throw new IllegalStateException("EAI_BATCH_SEND_DIR 디렉토리를 생성할 수 없음: " + prop.getUmsEaiBatchSendDir());
} }
} }
if (!sendDirPath.toFile().isDirectory()) { if (!sendDirPath.toFile().isDirectory()) {
log.error("EAI_BATCH_SEND_DIR 가 디렉토리가 아님: {}", prop.getEaiBatchSendDir()); log.error("EAI_BATCH_SEND_DIR 가 디렉토리가 아님: {}", prop.getUmsEaiBatchSendDir());
throw new IllegalStateException("EAI_BATCH_SEND_DIR 가 디렉토리가 아님: " + prop.getEaiBatchSendDir()); throw new IllegalStateException("EAI_BATCH_SEND_DIR 가 디렉토리가 아님: " + prop.getUmsEaiBatchSendDir());
} }
if (!sendDirPath.toFile().canWrite()) { if (!sendDirPath.toFile().canWrite()) {
log.error("EAI_BATCH_SEND_DIR 에 쓰기 권한이 없음: {}", prop.getEaiBatchSendDir()); log.error("EAI_BATCH_SEND_DIR 에 쓰기 권한이 없음: {}", prop.getUmsEaiBatchSendDir());
throw new IllegalStateException("EAI_BATCH_SEND_DIR 에 쓰기 권한이 없음: " + prop.getEaiBatchSendDir()); throw new IllegalStateException("EAI_BATCH_SEND_DIR 에 쓰기 권한이 없음: " + prop.getUmsEaiBatchSendDir());
} }
} }
public void sendEmail(MessageRequest messageRequest) { public void sendEmail(MessageRequest messageRequest) {
log.debug("sendEmail() called - EAI_BATCH_URL: {}, EAI_BATCH_SEND_DIR: {}", prop.getEaiBatchUrl(), prop.getEaiBatchSendDir()); log.debug("sendEmail() called - EAI_BATCH_URL: {}, EAI_BATCH_SEND_DIR: {}", prop.getEaiBatchUrl(), prop.getUmsEaiBatchSendDir());
log.debug("MessageRequest ID: {}, Email: {}", messageRequest.getId(), messageRequest.getEmail()); log.debug("MessageRequest ID: {}, Email: {}", messageRequest.getId(), messageRequest.getEmail());