This repository has been archived by the owner on Nov 21, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
49fb330
commit 7340e72
Showing
7 changed files
with
54 additions
and
19 deletions.
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
submodules/local-event/src/main/kotlin/com/sns/localevent/DomainEvent.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.sns.localevent | ||
|
||
interface DomainEvent { | ||
val eventId: String | ||
|
||
val channel: String | ||
} |
11 changes: 11 additions & 0 deletions
11
...dules/local-event/src/main/kotlin/com/sns/localevent/config/IntegrationEventBaseConfig.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package com.sns.localevent.config | ||
|
||
import com.sns.localevent.service.EventPublisher | ||
import org.springframework.context.ApplicationContext | ||
import org.springframework.context.annotation.Bean | ||
|
||
class IntegrationEventBaseConfig { | ||
|
||
@Bean | ||
fun eventPublisher(applicationContext: ApplicationContext) = EventPublisher(applicationContext) | ||
} |
19 changes: 19 additions & 0 deletions
19
submodules/local-event/src/main/kotlin/com/sns/localevent/service/EventPublisher.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package com.sns.localevent.service | ||
|
||
import com.sns.commons.utils.log | ||
import com.sns.localevent.DomainEvent | ||
import org.springframework.context.ApplicationContext | ||
import org.springframework.messaging.MessageChannel | ||
import org.springframework.messaging.support.GenericMessage | ||
|
||
class EventPublisher(private val applicationContext: ApplicationContext) { | ||
private val log = log() | ||
|
||
fun <T : DomainEvent> publish(domainEvent: T) { | ||
val channel = applicationContext.getBean(domainEvent.channel) as MessageChannel | ||
|
||
log.info("publish ${domainEvent.eventId}") | ||
|
||
channel.send(GenericMessage(domainEvent)) | ||
} | ||
} |
8 changes: 4 additions & 4 deletions
8
user-api/src/main/kotlin/com/sns/user/component/test/domains/TestUser.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 9 additions & 2 deletions
11
user-api/src/main/kotlin/com/sns/user/component/test/dtos/LaughingEvent.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,12 @@ | ||
package com.sns.user.component.test.dtos | ||
|
||
import com.sns.user.core.supports.DomainEvent | ||
import com.sns.localevent.DomainEvent | ||
import com.sns.user.core.config.IntegrationConfig | ||
|
||
class LaughingEvent(val who: String) : DomainEvent | ||
class LaughingEvent(val who: String) : DomainEvent { | ||
// FIMXE 예제용 임시 포맷 | ||
override val eventId: String | ||
get() = "$channel-$who-${System.currentTimeMillis()}" | ||
|
||
override val channel = IntegrationConfig.Channels.EMOTION | ||
} |
14 changes: 4 additions & 10 deletions
14
user-api/src/main/kotlin/com/sns/user/component/test/listeners/EmotionListener.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 0 additions & 3 deletions
3
user-api/src/main/kotlin/com/sns/user/core/supports/DomainEvent.kt
This file was deleted.
Oops, something went wrong.