260723_01_ENH: 문자발송 갱신 조건 변경 (1시간 이내 -> 현재 시간보다 작은 모든 것)

This commit is contained in:
2026-07-23 10:54:55 +09:00
parent 8043fc457c
commit 86f9d1b634
3 changed files with 25 additions and 24 deletions

View File

@@ -33,14 +33,20 @@ public interface SendRepository extends JpaRepository<TSendEntity, Long> {
from TSendEntity s from TSendEntity s
where s.sendStatus = :sendStatus where s.sendStatus = :sendStatus
and s.sendTy in :sendTyList and s.sendTy in :sendTyList
and s.sendDt between :fromDt and :toDt and s.resultCode in :resultCodes
and s.sendDt <= :now
and exists (
select 1
from BizLogEntity b
where b.cmid = s.cmid
)
order by s.sendIdx asc order by s.sendIdx asc
""") """)
List<TSendEntity> findSendListToRefreshWithinHours( List<TSendEntity> findSendListToRefresh(
List<Short> sendTyList, List<Short> sendTyList,
short sendStatus, short sendStatus,
LocalDateTime fromDt, List<Short> resultCodes,
LocalDateTime toDt, LocalDateTime now,
Pageable pageable Pageable pageable
); );

View File

@@ -38,22 +38,22 @@ public class BizLogResultScheduler {
private final BizLogRepository bizLogRepository; private final BizLogRepository bizLogRepository;
private final BulkSendRepository bulkSendRepository; private final BulkSendRepository bulkSendRepository;
@Value("${kri.sms.result-sync.window-hours:1}")
private long resultSyncWindowHours;
@Value("${kri.sms.result-sync.batch-size:1000}") @Value("${kri.sms.result-sync.batch-size:1000}")
private int resultSyncBatchSize; private int resultSyncBatchSize;
@Scheduled(fixedDelayString = "${kri.sms.result-sync.fixed-delay-ms:60000}") // 나중에 증가시킬 것 @Scheduled(fixedDelayString = "${kri.sms.result-sync.fixed-delay-ms:60000}")
@Transactional(transactionManager = "transactionManager") @Transactional(transactionManager = "transactionManager")
public void syncSmsResults() { public void syncSmsResults() {
TimeWindow window = buildWindow(resultSyncWindowHours);
List<Short> sendTyList = List.of(SendType.SMS.getCode(), SendType.LMS_MMS.getCode(), SendType.KKO_AT.getCode()); List<Short> sendTyList = List.of(SendType.SMS.getCode(), SendType.LMS_MMS.getCode(), SendType.KKO_AT.getCode());
List<Short> resultCodes = List.of(
NotihubConst.SMS_STANDBY,
NotihubConst.LMS_MMS_STANDBY,
NotihubConst.KKO_AT_STANDBY
);
while (true) { while (true) {
List<TSendEntity> batch = fetchRefreshTargets(sendTyList, window, resultSyncBatchSize); List<TSendEntity> batch = fetchRefreshTargets(sendTyList, resultCodes, resultSyncBatchSize);
if (batch.isEmpty()) { if (batch.isEmpty()) {
return; return;
} }
@@ -63,21 +63,20 @@ public class BizLogResultScheduler {
BatchResult result = applyResultsAndCollectDeltas(batch, bulkCtx); BatchResult result = applyResultsAndCollectDeltas(batch, bulkCtx);
persistChanges(result, bulkCtx); persistChanges(result, bulkCtx);
if (result.updatedSends().isEmpty()) {
return;
}
} }
} }
private TimeWindow buildWindow(long hours) { private List<TSendEntity> fetchRefreshTargets(List<Short> sendTyList, List<Short> resultCodes,
LocalDateTime toDt = LocalDateTime.now();
return new TimeWindow(toDt.minusHours(hours), toDt);
}
private List<TSendEntity> fetchRefreshTargets(List<Short> sendTyList, TimeWindow window,
int size) { int size) {
return sendRepository.findSendListToRefreshWithinHours( return sendRepository.findSendListToRefresh(
sendTyList, sendTyList,
SendStatusType.STANDBY.getCode(), SendStatusType.STANDBY.getCode(),
window.from(), resultCodes,
window.to(), LocalDateTime.now(),
PageRequest.of(0, size) PageRequest.of(0, size)
); );
} }
@@ -275,9 +274,6 @@ public class BizLogResultScheduler {
} }
} }
private record TimeWindow(LocalDateTime from, LocalDateTime to) {
}
private record BulkContext(Set<String> bulkKeys, Map<String, TBulkSendEntity> bulkMap) { private record BulkContext(Set<String> bulkKeys, Map<String, TBulkSendEntity> bulkMap) {

View File

@@ -55,7 +55,6 @@ kri:
sms: sms:
result-sync: result-sync:
fixed-delay-ms: 10000 fixed-delay-ms: 10000
window-hours: 1
batch-size: 1000 batch-size: 1000
auth: auth: