Skip to content

Commit

Permalink
fix: in-memory 큐 쓰던 것을 rabbitmq로 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
takoyakimchi committed Oct 23, 2024
1 parent efcc423 commit bc5201c
Showing 1 changed file with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import static com.happy.friendogly.chat.domain.MessageType.ENTER;
import static com.happy.friendogly.chat.domain.MessageType.LEAVE;

import com.happy.friendogly.chat.config.ChatTemplate;
import com.happy.friendogly.chat.domain.ChatMessage;
import com.happy.friendogly.chat.domain.ChatRoom;
import com.happy.friendogly.chat.domain.MessageType;
Expand All @@ -18,31 +19,29 @@
import com.happy.friendogly.member.repository.MemberRepository;
import com.happy.friendogly.notification.service.NotificationService;
import java.time.LocalDateTime;
import org.springframework.messaging.simp.SimpMessagingTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional
public class ChatCommandService {

private static final String TOPIC_CHAT_PREFIX = "/topic/chat/";
private static final String EMPTY_CONTENT = "";

private final MemberRepository memberRepository;
private final ClubRepository clubRepository;
private final ChatRoomRepository chatRoomRepository;
private final ChatMessageRepository chatMessageRepository;
private final NotificationService notificationService;
private final SimpMessagingTemplate template;
private final ChatTemplate template;

public ChatCommandService(
MemberRepository memberRepository,
ClubRepository clubRepository,
ChatRoomRepository chatRoomRepository,
ChatMessageRepository chatMessageRepository,
NotificationService notificationService,
SimpMessagingTemplate template
ChatTemplate template
) {
this.memberRepository = memberRepository;
this.clubRepository = clubRepository;
Expand Down Expand Up @@ -81,7 +80,7 @@ private void sendAndSave(MessageType messageType, String content, ChatRoom chatR
Club club = clubRepository.getByChatRoomId(chatRoom.getId());

notificationService.sendChatNotification(chatRoom.getId(), chat, club);
template.convertAndSend(TOPIC_CHAT_PREFIX + chatRoom.getId(), chat);
template.convertAndSend(chatRoom.getId(), chat);
chatMessageRepository.save(new ChatMessage(chatRoom, messageType, senderMember, content));
}
}

0 comments on commit bc5201c

Please sign in to comment.