SagaCompensationRunner

open class SagaCompensationRunner<S : Saga<S>, T : SagaStep<T>, TCommand : Any>(sagaRepository: SagaRepositoryPort<S>, sagaStepRepository: SagaStepRepositoryPort<T>, compensator: SagaCompensator<S, T, TCommand>, compensationContext: SagaCompensationContext<TCommand>) : SagaCompensationTrigger(source)

Transactional helper for SagaEngine that runs the compensation sequence in its own fresh transaction.

Extracted into a separate Spring bean so that calls go through the AOP proxy and actually open the requested REQUIRES_NEW transaction — @Transactional self-invocation on the same instance bypasses the proxy and runs without a transaction.

Created per service (one bean per SagaEngine) to keep the type parameters consistent with the owning engine.

Constructors

Link copied to clipboard
constructor(sagaRepository: SagaRepositoryPort<S>, sagaStepRepository: SagaStepRepositoryPort<T>, compensator: SagaCompensator<S, T, TCommand>, compensationContext: SagaCompensationContext<TCommand>)

Functions

Link copied to clipboard
@Transactional(propagation = Propagation.REQUIRES_NEW)
open override fun runCompensation(sagaId: String)

Runs the compensation pipeline for sagaId in a fresh REQUIRES_NEW transaction. No-op if the saga is in a terminal status (SagaStatus.COMPLETED, SagaStatus.COMPENSATED or SagaStatus.FAILED). Safe to call repeatedly — the watchdog uses this method to retry compensation for stuck sagas.