Skip to content

Commit

Permalink
refactor: AWS SNS를 통해 웹소켓 사용하도록 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
Hwanvely committed May 14, 2024
1 parent 7c72f46 commit 26a22a1
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 8 deletions.
8 changes: 3 additions & 5 deletions api/src/main/kotlin/gloddy/ChatController.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,9 @@ import org.springframework.stereotype.Controller
@Controller
class ChatController(private val groupChatCommander: GroupChatCommander) {

@MessageMapping("/chat/message/{chatId}")
fun sendChat(@DestinationVariable chatId: String, createMessageCommand: GroupChatCreateMessageCommand) {
groupChatCommander.createMessage(createMessageCommand)
@MessageMapping("{chatId}")
fun sendChat(@DestinationVariable chatId: String, command: GroupChatCreateMessageCommand) {
groupChatCommander.createMessage(command)

// messagingTemplate.convertAndSend("/sub/chat$chatId", createMessageCommand)
// 위 코드는 SQS를 처리하는 곳으로 이전되어야 함
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ import gloddy.groupChat.event.GroupChatEvent

interface MessageEventProducer {

fun produceEvent(groupChatEvent: GroupChatEvent?)
fun produceEvent(groupChatEvent: GroupChatEvent)
}
1 change: 1 addition & 0 deletions out-message/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
dependencies {
implementation(project(":domain"))
compileOnly("org.springframework:spring-tx")
implementation(platform("io.awspring.cloud:spring-cloud-aws-dependencies:3.0.3"))
implementation("io.awspring.cloud:spring-cloud-aws-starter-sns")
}
11 changes: 11 additions & 0 deletions out-message/src/main/kotlin/gloddy/sns/config/SnsConfig.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,18 @@
package gloddy.sns.config

import io.awspring.cloud.sns.core.TopicArnResolver
import io.awspring.cloud.sns.core.TopicsListingTopicArnResolver
import org.springframework.boot.context.properties.EnableConfigurationProperties
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
import software.amazon.awssdk.services.sns.SnsClient

@Configuration
@EnableConfigurationProperties(SnsProperties::class)
class SnsConfig {

@Bean
fun topicArnResolver(snsClient: SnsClient): TopicArnResolver {
return TopicsListingTopicArnResolver(snsClient)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import org.springframework.stereotype.Component
@Component
@ConfigurationProperties("spring.cloud")
class SnsProperties {
var event: Map<String, String>? = null
var event: Map<String, String> = HashMap<String, String>()

fun getTopic(key: String): String? {
return event!![key]
return event[key]
}
}

0 comments on commit 26a22a1

Please sign in to comment.