Skip to content

Commit 424c442

Browse files
committed
Revert "revert(chat): Revert WebSocket/RabbitMQ changes"
This reverts commit a2bdeb8.
1 parent a2bdeb8 commit 424c442

File tree

4 files changed

+9
-11
lines changed

4 files changed

+9
-11
lines changed
Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,20 @@
11
package com.back.koreaTravelGuide.domain.userChat.chatmessage.usecase
22

3-
import org.springframework.amqp.rabbit.core.RabbitTemplate
43
import org.springframework.context.annotation.Profile
4+
import org.springframework.messaging.simp.SimpMessagingTemplate
55
import org.springframework.stereotype.Component
66

77
@Profile("prod")
88
@Component
99
class RabbitChatMessagePublisher(
10-
// private val messagingTemplate: SimpMessagingTemplate,
11-
private val rabbitTemplate: RabbitTemplate,
10+
private val messagingTemplate: SimpMessagingTemplate,
1211
) : ChatMessagePublisher {
1312
override fun publishUserChat(
1413
roomId: Long,
1514
payload: Any,
1615
) {
17-
val routingKey = "userchat.$roomId"
18-
rabbitTemplate.convertAndSend("amq.topic", routingKey, payload)
1916
// STOMP Broker Relay를 통해 RabbitMQ로 메시지 발행
2017
// enableStompBrokerRelay("/topic") 설정에 의해 자동으로 RabbitMQ STOMP Broker로 라우팅됨
21-
// messagingTemplate.convertAndSend("/topic/userchat/$roomId", payload)
18+
messagingTemplate.convertAndSend("/topic/userchat/$roomId", payload)
2219
}
2320
}

src/main/kotlin/com/back/koreaTravelGuide/domain/userChat/stomp/UserChatRabbitWebSocketConfig.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class UserChatRabbitWebSocketConfig(
2727
override fun registerStompEndpoints(registry: StompEndpointRegistry) {
2828
registry.addEndpoint("/ws/userchat")
2929
.setAllowedOriginPatterns("*")
30-
// .setAllowedOrigins("https://www.team11.giwon11292.com", "http://localhost:3000")
30+
.setAllowedOrigins("https://www.team11.giwon11292.com", "http://localhost:3000")
3131
.withSockJS()
3232
}
3333

src/main/kotlin/com/back/koreaTravelGuide/domain/userChat/stomp/UserChatSimpleWebSocketConfig.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class UserChatSimpleWebSocketConfig(
1717
override fun registerStompEndpoints(registry: StompEndpointRegistry) {
1818
registry.addEndpoint("/ws/userchat")
1919
.setAllowedOriginPatterns("*")
20-
// .setAllowedOrigins("https://www.team11.giwon11292.com", "http://localhost:3000")
20+
.setAllowedOrigins("https://www.team11.giwon11292.com", "http://localhost:3000")
2121
.withSockJS()
2222
}
2323

src/main/kotlin/com/back/koreaTravelGuide/domain/userChat/stomp/UserChatStompAuthChannelInterceptor.kt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.back.koreaTravelGuide.domain.userChat.stomp
22

3+
import com.back.koreaTravelGuide.common.logging.log
34
import com.back.koreaTravelGuide.common.security.JwtTokenProvider
45
import org.springframework.messaging.Message
56
import org.springframework.messaging.MessageChannel
@@ -20,7 +21,7 @@ class UserChatStompAuthChannelInterceptor(
2021
): Message<*>? {
2122
val accessor = MessageHeaderAccessor.getAccessor(message, StompHeaderAccessor::class.java) ?: return message
2223

23-
// log.info("📨 [STOMP] Command: ${accessor.command}, User: ${accessor.user}, SessionId: ${accessor.sessionId}")
24+
log.info("📨 [STOMP] Command: ${accessor.command}, User: ${accessor.user}, SessionId: ${accessor.sessionId}")
2425

2526
if (accessor.command == StompCommand.CONNECT) {
2627
val rawHeader =
@@ -31,9 +32,9 @@ class UserChatStompAuthChannelInterceptor(
3132
throw AuthenticationCredentialsNotFoundException("Invalid JWT token")
3233
}
3334
accessor.user = jwtTokenProvider.getAuthentication(token)
34-
// log.info("✅ [STOMP] CONNECT authenticated: userId=${accessor.user?.name}")
35+
log.info("✅ [STOMP] CONNECT authenticated: userId=${accessor.user?.name}")
3536
} else if (accessor.user == null) {
36-
// log.error("❌ [STOMP] Unauthenticated ${accessor.command} request - SessionId: ${accessor.sessionId}")
37+
log.error("❌ [STOMP] Unauthenticated ${accessor.command} request - SessionId: ${accessor.sessionId}")
3738
throw AuthenticationCredentialsNotFoundException("Unauthenticated STOMP request")
3839
}
3940

0 commit comments

Comments
 (0)