SagaWatchdog

open class SagaWatchdog<S : Saga<S>, T : SagaStep<T>>(sagaRepository: SagaRepositoryPort<S>, sagaEngine: SagaEngine<S, T>, properties: SagaProperties)(source)

Per-service watchdog that:

  1. Times out sagas stuck in SagaStatus.AWAITING_RESPONSE for longer than SagaProperties.awaitResponseTimeout (calls SagaEngine.failSaga which schedules compensation).

  2. Retries compensation for sagas that are still SagaStatus.COMPENSATING or that ended in SagaStatus.COMPENSATION_FAILED and whose updatedAt is older than SagaProperties.compensationRetryCooldown.

Created per service (analogous to the per-service SagaEngine bean) so each microservice's saga state machine has its own scheduled watchdog.

Constructors

Link copied to clipboard
constructor(sagaRepository: SagaRepositoryPort<S>, sagaEngine: SagaEngine<S, T>, properties: SagaProperties)

Functions

Link copied to clipboard
@Scheduled(fixedDelayString = "${veds.saga.watchdog-interval:PT1M}")
fun tick()

Scheduled tick fired every veds.saga.watchdog-interval (default PT1M). Times out stuck AWAITING_RESPONSE sagas and retries failed compensations. Designed to be idempotent and safe to run on every node — each operation goes through SagaEngine which guards against re-entry on terminal sagas.