22
33import 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 ;
59import org .springframework .stereotype .Component ;
610
711import com .google .firebase .messaging .FirebaseMessaging ;
812import com .google .firebase .messaging .Message ;
913import com .google .firebase .messaging .WebpushConfig ;
1014import com .google .firebase .messaging .WebpushNotification ;
1115
16+ import lombok .RequiredArgsConstructor ;
17+
1218@ Component
19+ @ RequiredArgsConstructor
1320public 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