@@ -51,6 +51,7 @@ public class ChatRoomService {
5151 private final KafkaProducer kafkaProducer ;
5252
5353 private static final String CHAT_REQUEST_KEY = "chatRequest" ;
54+ private static final String TOPIC = "alert-topic" ;
5455
5556 // 요청을 Redis에 저장 (TTL: 60초)
5657 public ResponseResult saveRequestToRedis (Long requestUserId , Long emotionRecordId ) {
@@ -98,7 +99,7 @@ public ResponseResult saveRequestToRedis(Long requestUserId, Long emotionRecordI
9899 .orElseThrow (UserNotFoundException ::new );
99100 AlertChatRequest alertChatRequest = new AlertChatRequest (emotionRecordId , requestUser .getNickname ());
100101 Alert alert = alertService .createAlert (responseUserId , "alarm" , alertChatRequest );
101- kafkaProducer .send ("alert-topic" , alert );
102+ kafkaProducer .send (TOPIC , alert );
102103
103104 return new ResponseResult (ErrorCode .SUCCESS );
104105 } catch (EmotionRecordNotFoundException e ) {
@@ -124,7 +125,7 @@ public ResponseResult deleteRequestFromRedis(Long userId, Long emotionRecordId)
124125 if (Boolean .TRUE .equals (redisTemplate .hasKey (key ))) {
125126 redisTemplate .delete (key );
126127 Alert alert = alertService .createAlert (recordIdInUserId , "cancel" , "Chat request has been canceled." );
127- kafkaProducer .send ("alert-topic" , alert );
128+ kafkaProducer .send (TOPIC , alert );
128129 log .info ("tset" );
129130 return new ResponseResult (ErrorCode .SUCCESS );
130131 } else {
@@ -160,7 +161,7 @@ public ResponseResult requestRejected(Long responseUserId, ChatRejectDto chatRej
160161 if (Boolean .TRUE .equals (redisTemplate .hasKey (key ))) {
161162 redisTemplate .delete (key );
162163 Alert alert = alertService .createAlert (requestUserId , "fail" , "채팅 요청을 거부했습니다" );
163- kafkaProducer .send ("alert-topic" , alert );
164+ kafkaProducer .send (TOPIC , alert );
164165 return new ResponseResult (ErrorCode .SUCCESS );
165166 } else {
166167 return new ResponseResult (400 , "ChatRequest not found or expired." );
@@ -210,7 +211,7 @@ public ResponseResult createChatRoom(Long userId, Long recordId, String requestN
210211 Map <String , Object > map = new HashMap <>();
211212 map .put ("chatRoomId" , chatRoomId .get ());
212213 Alert alert = alertService .createAlert (requestUserId , "accept" , map );
213- kafkaProducer .send ("alert-topic" , alert );
214+ kafkaProducer .send (TOPIC , alert );
214215 return new ResponseResult (map );
215216 }
216217
@@ -238,7 +239,7 @@ public ResponseResult createChatRoom(Long userId, Long recordId, String requestN
238239
239240 // 요청자에게 방번호를 보냄
240241 Alert alert = alertService .createAlert (requestUserId , "accept" , map );
241- kafkaProducer .send ("alert-topic" , alert );
242+ kafkaProducer .send (TOPIC , alert );
242243
243244 return new ResponseResult (map );
244245 } else {
0 commit comments