DefaultSagaCompensationContext

class DefaultSagaCompensationContext<TCommand : Any>(kafkaOutboxProcessor: KafkaOutboxProcessor, compensationEventSerializer: CompensationEventSerializer<TCommand>, compensationTopic: String, objectMapper: ObjectMapper) : SagaCompensationContext<TCommand> (source)

Default SagaCompensationContext implementation shared by SagaEngine and SagaCompensationRunner.

Extracted out of the engine so the runner can be constructed without a circular dependency on the engine: both collaborators receive the same context instance from configuration.

Constructors

Link copied to clipboard
constructor(kafkaOutboxProcessor: KafkaOutboxProcessor, compensationEventSerializer: CompensationEventSerializer<TCommand>, compensationTopic: String, objectMapper: ObjectMapper)

Functions

Link copied to clipboard
open override fun publishCompensationEvent(sagaId: String, stepId: Long?, command: TCommand)

Publishes a typed compensation command to the service-local compensation topic via the Transactional Outbox.

Link copied to clipboard
open override fun readStepPayload(payload: String?): Map<String, Any?>

Deserializes the step payload (JSON, written by the saga engine on step recording) into a Map. Returns an empty map when the payload is null/blank. Use it inside SagaCompensator to read the data captured at step-record time and assemble the typed TCommand.