configure rabbitMQ ConnectionFactory
This commit is contained in:
@@ -13,10 +13,18 @@ fun appKoinModule(config: Configuration) =
|
|||||||
data class Configuration(
|
data class Configuration(
|
||||||
val redisUrl: String,
|
val redisUrl: String,
|
||||||
val postgresql: Postgresql,
|
val postgresql: Postgresql,
|
||||||
|
val rabbitmq: RabbitMQ,
|
||||||
) {
|
) {
|
||||||
data class Postgresql(
|
data class Postgresql(
|
||||||
val url: String,
|
val url: String,
|
||||||
val username: String,
|
val username: String,
|
||||||
val password: String,
|
val password: String,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
data class RabbitMQ(
|
||||||
|
val url: String,
|
||||||
|
val port: Int,
|
||||||
|
val username: String,
|
||||||
|
val password: String,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package eventDemo.configuration.injection
|
package eventDemo.configuration.injection
|
||||||
|
|
||||||
|
import com.rabbitmq.client.ConnectionFactory
|
||||||
import com.zaxxer.hikari.HikariConfig
|
import com.zaxxer.hikari.HikariConfig
|
||||||
import com.zaxxer.hikari.HikariDataSource
|
import com.zaxxer.hikari.HikariDataSource
|
||||||
import eventDemo.adapter.infrastructureLayer.event.GameEventBusInMemory
|
import eventDemo.adapter.infrastructureLayer.event.GameEventBusInMemory
|
||||||
@@ -38,6 +39,16 @@ fun Module.configureDIInfrastructure(config: Configuration) {
|
|||||||
}
|
}
|
||||||
} bind DataSource::class
|
} bind DataSource::class
|
||||||
|
|
||||||
|
single {
|
||||||
|
ConnectionFactory().apply {
|
||||||
|
host = config.rabbitmq.url
|
||||||
|
port = config.rabbitmq.port
|
||||||
|
virtualHost = virtualHost
|
||||||
|
username = config.rabbitmq.username
|
||||||
|
password = config.rabbitmq.password
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
singleOf(::GameEventBusInMemory) bind GameEventBus::class
|
singleOf(::GameEventBusInMemory) bind GameEventBus::class
|
||||||
singleOf(::GameEventStoreInPostgresql) bind GameEventStore::class
|
singleOf(::GameEventStoreInPostgresql) bind GameEventStore::class
|
||||||
singleOf(::GameProjectionBusInMemory) bind GameProjectionBus::class
|
singleOf(::GameProjectionBusInMemory) bind GameProjectionBus::class
|
||||||
|
|||||||
@@ -29,6 +29,13 @@ fun ApplicationConfig.configuration() =
|
|||||||
username = getProperty("postgresql.username"),
|
username = getProperty("postgresql.username"),
|
||||||
password = getProperty("postgresql.password"),
|
password = getProperty("postgresql.password"),
|
||||||
),
|
),
|
||||||
|
rabbitmq =
|
||||||
|
Configuration.RabbitMQ(
|
||||||
|
url = getProperty("rabbitmq.url"),
|
||||||
|
port = getProperty("rabbitmq.port").toInt(),
|
||||||
|
username = getProperty("rabbitmq.username"),
|
||||||
|
password = getProperty("rabbitmq.password"),
|
||||||
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
private fun ApplicationConfig.getProperty(path: String): String =
|
private fun ApplicationConfig.getProperty(path: String): String =
|
||||||
|
|||||||
@@ -26,4 +26,18 @@ postgresql {
|
|||||||
|
|
||||||
password = "changeit"
|
password = "changeit"
|
||||||
password = ${?POSTGRESQL_PASSWORD}
|
password = ${?POSTGRESQL_PASSWORD}
|
||||||
|
}
|
||||||
|
|
||||||
|
rabbitmq {
|
||||||
|
url = "localhost"
|
||||||
|
url = ${?RABBITMQ_URL}
|
||||||
|
|
||||||
|
port = "5672"
|
||||||
|
port = ${?RABBITMQ_PORT}
|
||||||
|
|
||||||
|
username = "event-demo"
|
||||||
|
username = ${?RABBITMQ_USERNAME}
|
||||||
|
|
||||||
|
password = "changeit"
|
||||||
|
password = ${?RABBITMQ_PASSWORD}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user