Skip to content

Commit

Permalink
[BUG] 이벤트 발행에 대한 Recover 메서드 추가 구현, 이벤트 발행 시, achievementId, progress…
Browse files Browse the repository at this point in the history
…Count 추가 전달 (#281)
  • Loading branch information
JIN-076 authored Mar 20, 2024
1 parent a92ba80 commit bc2d626
Showing 1 changed file with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ public class AchievementEventService {
private final AchievementFacadeService achievementFacadeService;
private final ApplicationEventPublisher eventPublisher;

// 작업과 동시에 업적 달성이 가능한, progressCount 최솟값
private final Integer MIN_PROGRESS_COUNT = 1;

// 달성 자격요건의 검증 없이 한 번에 달성 가능한 업적에 대한 이벤트 발행
@Async("threadPoolTaskExecutor")
@Retryable(retryFor = EventListenerProcessingException.class, maxAttempts = 3, backoff = @Backoff(1000))
Expand All @@ -48,6 +51,8 @@ public void publishCompletedEventWithoutVerify(Long userId, ActivityType activit
UserActivityEvent.builder()
.userId(userId)
.activityType(activityType)
.achievementId(achievementId)
.progressCount(MIN_PROGRESS_COUNT)
.build()
);

Expand Down Expand Up @@ -91,6 +96,8 @@ public void publishCompletedEventWithVerify(Long userId, ActivityType activityTy
UserActivityEvent.builder()
.userId(userId)
.activityType(activityType)
.achievementId(achievementId)
.progressCount((Integer) target)
.build()
);

Expand Down Expand Up @@ -131,6 +138,8 @@ public void publishAccumulateEventWithVerify(Long userId, ActivityType activityT
UserActivityEvent.builder()
.userId(userId)
.activityType(activityType)
.achievementId(achievementId)
.progressCount(progressCount)
.build()
);

Expand Down Expand Up @@ -247,6 +256,18 @@ public void recoverForEventListenerProcess(
throw new AchievementException(ErrorCode400.EVENT_LISTENER_REQUEST_FAILED);
}

@Recover
public void recoverForEventListenerProcess(
EventListenerProcessingException e, Long userId, ActivityType activityType, Integer progressCount) {
throw new AchievementException(ErrorCode400.EVENT_LISTENER_REQUEST_FAILED);
}

@Recover
public void recoverForEventListenerProcess(
EventListenerProcessingException e, Long userId, ActivityType activityType, Object target) {
throw new AchievementException(ErrorCode400.EVENT_LISTENER_REQUEST_FAILED);
}

private boolean validateAvailabilityToAchieve(Object target, Long achievementId) {
Achievement achievement = achievementFacadeService.getById(achievementId);
if (target instanceof Integer) {
Expand Down

0 comments on commit bc2d626

Please sign in to comment.