diff --git a/k-es-jdbc/src/test/kotlin/no/ks/kes/jdbc/MSSQLContainerTest.kt b/k-es-jdbc/src/test/kotlin/no/ks/kes/jdbc/MSSQLContainerTest.kt index b20b31f0..5efb4ed7 100644 --- a/k-es-jdbc/src/test/kotlin/no/ks/kes/jdbc/MSSQLContainerTest.kt +++ b/k-es-jdbc/src/test/kotlin/no/ks/kes/jdbc/MSSQLContainerTest.kt @@ -97,6 +97,7 @@ class MSSQLContainerTest : StringSpec() { Sagas.initialize(eventSubscriberFactory = kesTest.subscriberFactory, sagaRepository = sagaRepository, sagas = setOf(EngineSaga), + subscriptionName = "EngineSaga", commandQueue = commandQueue, pollInterval = 1000, onError = { diff --git a/k-es-lib/src/main/kotlin/no/ks/kes/lib/Sagas.kt b/k-es-lib/src/main/kotlin/no/ks/kes/lib/Sagas.kt index 69dbbec8..d8526148 100644 --- a/k-es-lib/src/main/kotlin/no/ks/kes/lib/Sagas.kt +++ b/k-es-lib/src/main/kotlin/no/ks/kes/lib/Sagas.kt @@ -17,13 +17,14 @@ object Sagas { sagas: Set>, commandQueue: CommandQueue, pollInterval: Long = 5000, + subscriptionName: String = SAGA_SUBSCRIBER, onError: (Exception) -> Unit = defaultOnCloseHandler ): S { val validSagaConfigurations = sagas.map { it.getConfiguration { eventSubscriberFactory.getSerializationId(it) } } val subscription = eventSubscriberFactory.createSubscriber( - hwmId = SAGA_SUBSCRIBER, - fromEvent = sagaRepository.hwmTracker.getOrInit(SAGA_SUBSCRIBER), + hwmId = subscriptionName, + fromEvent = sagaRepository.hwmTracker.getOrInit(subscriptionName), onEvent = { wrapper -> sagaRepository.transactionally { try { @@ -36,7 +37,7 @@ object Sagas { }) }.toSet() ) - sagaRepository.hwmTracker.update(SAGA_SUBSCRIBER, wrapper.eventNumber) + sagaRepository.hwmTracker.update(subscriptionName, wrapper.eventNumber) } catch (e: Exception) { log.error("An error was encountered while handling incoming event ${wrapper.event::class.simpleName} with sequence number ${wrapper.eventNumber}", e) throw e @@ -46,7 +47,7 @@ object Sagas { onError = onError ) - Timer("PollingTimeouts", false).schedule(0, pollInterval) { + Timer("${subscriptionName}-PollingTimeouts", false).schedule(0, pollInterval) { sagaRepository.transactionally { sagaRepository.getReadyTimeouts() ?.let { timeout -> @@ -74,7 +75,7 @@ object Sagas { } } - Timer("PollingCommandQueue", false).schedule(0, pollInterval) { + Timer("${subscriptionName}-PollingCommandQueue", false).schedule(0, pollInterval) { try { commandQueue.poll() } catch (e: Exception) {