Skip to content

Commit c7aa0a7

Browse files
committed
fix: 비동기 처리 정상적으로 동작하도록 수정 (WR9-143) #246
1 parent f364a47 commit c7aa0a7

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

src/main/java/io/crops/warmletter/domain/timeline/facade/NotificationFacade.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package io.crops.warmletter.domain.timeline.facade;
22

33
import io.crops.warmletter.domain.timeline.dto.request.NotificationRequest;
4-
import io.crops.warmletter.domain.timeline.enums.AlarmType;
54
import io.crops.warmletter.domain.timeline.service.NotificationService;
65
import lombok.RequiredArgsConstructor;
76
import org.springframework.scheduling.annotation.Async;

src/main/java/io/crops/warmletter/domain/timeline/service/NotificationService.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package io.crops.warmletter.domain.timeline.service;
22

3-
import io.crops.warmletter.domain.auth.exception.UnauthorizedException;
43
import io.crops.warmletter.domain.auth.facade.AuthFacade;
54
import io.crops.warmletter.domain.timeline.dto.response.NotificationResponse;
65
import io.crops.warmletter.domain.timeline.entity.Timeline;
@@ -9,6 +8,7 @@
98
import lombok.RequiredArgsConstructor;
109
import lombok.extern.slf4j.Slf4j;
1110
import org.springframework.http.MediaType;
11+
import org.springframework.scheduling.annotation.Async;
1212
import org.springframework.scheduling.annotation.Scheduled;
1313
import org.springframework.stereotype.Service;
1414
import org.springframework.transaction.annotation.Transactional;
@@ -57,7 +57,9 @@ protected void handleTimeout(Long memberId, SseEmitter emitter) {
5757
}
5858

5959
// 편지 수신, 신고 조치, 공유 요청, 공유 게시글 등록 시 호출 필요
60-
public void createNotification(String senderZipCode, Long receiverId, AlarmType alarmType, String data){
60+
@Transactional
61+
public void createNotification(String senderZipCode, Long receiverId, AlarmType alarmType, String data) {
62+
6163
Timeline.TimelineBuilder builder = Timeline.builder()
6264
.memberId(receiverId)
6365
// data = LETTER: letterId / REPORT: adminMemo, 경고횟수 / SHARE: shareProposalId / POSTED: sharePostId
@@ -111,6 +113,7 @@ protected void sendEventToClient(Long receiverId, NotificationResponse notificat
111113
}
112114

113115
// 연결을 확인하기 위한 Heartbeat를 30초마다 실행
116+
@Async
114117
@Scheduled(fixedRate = 30000)
115118
public void sendHeartbeat() {
116119
NotificationResponse notificationResponse = NotificationResponse.builder()
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package io.crops.warmletter.global.config;
2+
3+
import org.springframework.context.annotation.Configuration;
4+
import org.springframework.scheduling.annotation.EnableAsync;
5+
6+
@Configuration
7+
@EnableAsync
8+
public class AsyncConfig {
9+
}

0 commit comments

Comments
 (0)