Skip to content

Commit fe2800a

Browse files
committed
feat: fcm 알림 실패 추적을 위한 로그 수정
1 parent cb2234d commit fe2800a

1 file changed

Lines changed: 16 additions & 2 deletions

File tree

src/main/java/org/scoula/global/firebase/util/FirebaseUtil.java

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,25 @@
22

33
import java.util.List;
44

5+
import org.scoula.global.kafka.dto.Common;
6+
import org.scoula.global.kafka.dto.LogLevel;
7+
import org.scoula.global.kafka.producer.KafkaProducer;
8+
import org.scoula.global.kafka.util.LogMessageMapper;
59
import org.springframework.stereotype.Component;
610

711
import com.google.firebase.messaging.FirebaseMessaging;
812
import com.google.firebase.messaging.Message;
913
import com.google.firebase.messaging.WebpushConfig;
1014
import com.google.firebase.messaging.WebpushNotification;
1115

16+
import lombok.RequiredArgsConstructor;
17+
1218
@Component
19+
@RequiredArgsConstructor
1320
public class FirebaseUtil {
21+
22+
private final KafkaProducer kafkaProducer;
23+
1424
public void sendNotices(List<String> tokens, String title, String body) {
1525
for (String token : tokens) {
1626
Message message = Message.builder()
@@ -24,7 +34,9 @@ public void sendNotices(List<String> tokens, String title, String body) {
2434
try {
2535
String send = FirebaseMessaging.getInstance().send(message);
2636
} catch (Exception e) {
27-
throw new RuntimeException(e);
37+
kafkaProducer.sendToLogTopic(
38+
LogMessageMapper.buildLogMessage(LogLevel.INFO, null, "fcm 알림 전송 실패", Common.builder().build(),
39+
e.toString()));
2840
}
2941
}
3042
}
@@ -41,7 +53,9 @@ public void sendNotice(String token, String title, String body) {
4153
try {
4254
String send = FirebaseMessaging.getInstance().send(message);
4355
} catch (Exception e) {
44-
throw new RuntimeException(e);
56+
kafkaProducer.sendToLogTopic(
57+
LogMessageMapper.buildLogMessage(LogLevel.INFO, null, "fcm 알림 전송 실패", Common.builder().build(),
58+
e.toString()));
4559
}
4660
}
4761
}

0 commit comments

Comments
 (0)