|
1 | 1 | package io.crops.warmletter.domain.timeline.service; |
2 | 2 |
|
3 | | -import io.crops.warmletter.domain.auth.exception.UnauthorizedException; |
4 | 3 | import io.crops.warmletter.domain.auth.facade.AuthFacade; |
5 | 4 | import io.crops.warmletter.domain.timeline.dto.response.NotificationResponse; |
6 | 5 | import io.crops.warmletter.domain.timeline.entity.Timeline; |
|
9 | 8 | import lombok.RequiredArgsConstructor; |
10 | 9 | import lombok.extern.slf4j.Slf4j; |
11 | 10 | import org.springframework.http.MediaType; |
| 11 | +import org.springframework.scheduling.annotation.Async; |
12 | 12 | import org.springframework.scheduling.annotation.Scheduled; |
13 | 13 | import org.springframework.stereotype.Service; |
14 | 14 | import org.springframework.transaction.annotation.Transactional; |
@@ -57,7 +57,9 @@ protected void handleTimeout(Long memberId, SseEmitter emitter) { |
57 | 57 | } |
58 | 58 |
|
59 | 59 | // 편지 수신, 신고 조치, 공유 요청, 공유 게시글 등록 시 호출 필요 |
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 | + |
61 | 63 | Timeline.TimelineBuilder builder = Timeline.builder() |
62 | 64 | .memberId(receiverId) |
63 | 65 | // data = LETTER: letterId / REPORT: adminMemo, 경고횟수 / SHARE: shareProposalId / POSTED: sharePostId |
@@ -111,6 +113,7 @@ protected void sendEventToClient(Long receiverId, NotificationResponse notificat |
111 | 113 | } |
112 | 114 |
|
113 | 115 | // 연결을 확인하기 위한 Heartbeat를 30초마다 실행 |
| 116 | + @Async |
114 | 117 | @Scheduled(fixedRate = 30000) |
115 | 118 | public void sendHeartbeat() { |
116 | 119 | NotificationResponse notificationResponse = NotificationResponse.builder() |
|
0 commit comments