You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
44 lines
1.2 KiB
Kotlin
44 lines
1.2 KiB
Kotlin
package wf.servitor.common
|
|
|
|
import org.apache.activemq.artemis.api.core.client.ActiveMQClient
|
|
import org.apache.activemq.artemis.api.core.client.ClientSession
|
|
import org.apache.activemq.artemis.api.core.client.ClientSessionFactory
|
|
import org.apache.activemq.artemis.api.core.client.ServerLocator
|
|
import org.koin.core.qualifier.named
|
|
import org.koin.core.scope.Scope
|
|
import org.koin.dsl.module
|
|
import wf.servitor.common.config.Config
|
|
import wf.servitor.common.config.createConfig
|
|
import wf.servitor.common.event.Session
|
|
|
|
fun Scope.config(): Config = get()
|
|
|
|
val commonModule = module {
|
|
single { createConfig(getOrNull(named("argument.config"))) }
|
|
|
|
single { ActiveMQClient.createServerLocator(config().queue.url) }
|
|
|
|
single { get<ServerLocator>().createSessionFactory() }
|
|
|
|
single {
|
|
val serverLocator: ServerLocator = get()
|
|
val config = config().queue
|
|
|
|
get<ClientSessionFactory>().createSession(
|
|
config.username,
|
|
config.password,
|
|
false,
|
|
true,
|
|
true,
|
|
false,
|
|
serverLocator.ackBatchSize
|
|
)
|
|
}
|
|
|
|
single { get<ClientSession>().createProducer() }
|
|
|
|
single(named("queue.task")) {
|
|
Session(get(), config().queue.names.taskQueue)
|
|
}
|
|
}
|