create GameEventBusInRabbinMQ and use it as GameEventBus

This commit is contained in:
2025-04-14 23:40:13 +02:00
parent 5f992f887d
commit 9e3c1267bf
2 changed files with 27 additions and 3 deletions
@@ -0,0 +1,25 @@
package eventDemo.adapter.infrastructureLayer.event
import com.rabbitmq.client.ConnectionFactory
import eventDemo.business.event.GameEventBus
import eventDemo.business.event.event.GameEvent
import eventDemo.libs.bus.Bus
import eventDemo.libs.bus.BusInRabbitMQ
import kotlinx.serialization.json.Json
import java.util.UUID
class GameEventBusInRabbinMQ(
private val connectionFactory: ConnectionFactory,
) : GameEventBus,
Bus<GameEvent> by BusInRabbitMQ(
connectionFactory,
"GameEvent",
{ Json.encodeToString(it) },
{ Json.decodeFromString<GameEvent>(it) },
),
Comparable<GameEventBusInRabbinMQ> {
private val instanceId: UUID = UUID.randomUUID()
override fun compareTo(other: GameEventBusInRabbinMQ): Int =
compareValues(instanceId, other.instanceId)
}