사용자 요청 → 외부 API 호출 → DB 저장
치명적 상황들:
@Transactional
public void processSingleMessage(Long batchId, String recipient) {
// 1️⃣ 히스토리 먼저 생성 (PENDING)
History history = createHistory(batchId, recipient, PENDING);
// 2️⃣ DB 저장 성공 시에만 API 호출
if (history != null) {
ApiResult result = coolSmsApi.send(recipient, message);
updateHistory(history.getId(), result.isSuccess() ? SUCCESS : FAILED);
}
}