A compensating transaction reverses a previously committed transaction. It is a core mechanism in the saga pattern, used to restore data consistency across services where traditional ACID rollback is not available.
A compensating transaction reverses a previously committed transaction. It is a core mechanism in the saga pattern, used to restore data consistency across services where traditional ACID rollback is not available.
In choreography-based sagas, there is no central coordinator. Each service publishes domain events after its local transaction. Other services subscribe to those events and independently decide what action to take next.
The Saga pattern embraces eventual consistency. Between steps, the system may hold a briefly inconsistent state. A debit can commit before its corresponding credit is processed — an accepted trade-off for availability.
In orchestration-based sagas, a central coordinator — the orchestrator — sends commands to participant services in sequence, tracks state, and triggers compensating transactions when a step fails.
Sagas do not provide automatic rollback. Developers must explicitly design a compensating transaction for each step that can succeed before the overall saga fails — a key difference from ACID database transactions.
The Saga pattern embraces eventual consistency. Between steps, the system may hold a briefly inconsistent state. A debit can commit before its corresponding credit is processed — an accepted trade-off for availability.
The Saga pattern manages distributed transactions in microservices as a sequence of local transactions. Each service updates its own database and triggers the next step via an event. It replaces 2PC to maintain consistency without cross-service locks.
Post-OOP Imperative Functional Java.
Model the process. Not the domain.
Most Java code still asks the wrong question:
"What is this domain object?"
But production systems fail, scale, and burn because of processes, not nouns.
If your system is a sequence of irreversible steps, model it as a sequence,
not as interacting objects pretending to be immortal.
This follows ideas from Railway-Oriented Programming (ROP):
errors and decisions are values, not control-flow side effects.
Modeling the process means you can read this top to bottom
and understand exactly what happens.
No debugger. No IDE magic. No tribal knowledge.
Control flow is explicit.
You see the execution order.
Nothing hides in constructors, annotations, or overrides.
Failure is a first-class concept.
Once it fails or decides early, nothing else runs.
No exception archaeology.
Processes > Objects.
Real systems are workflows where refactoring is safe.
Steps are reordered, removed, or replaced
without collapsing a class hierarchy.
Testing is trivial, small stepwise context — even for an AI.
Feed input. Assert final result.
No mocking five layers of indirection.
GraalVM / native-friendly.
No reflection rituals.
The compiler smiles.
Objects are great for long-lived entities.
User actions, payments, rules, and failures are short-lived processes.
I model what happens,
not what pretends to exist forever.
Influenced by:
Railway-Oriented Programming,
Functional Core / Imperative Shell,
Workflow / Saga patterns,
Command pipelines,
Unix philosophy,
and value-oriented libraries like Vanilla-DI.
Don't be stuck in axioms.
#PostOOP
#ImperativeFunctional
#ProcessOverObjects
#ModelTheProcess
#WorkflowFirst
#RailwayOrientedProgramming
#FunctionalCore
#ImperativeShell
#CommandPipeline
#ExplicitControlFlow
#ValueOrientedDesign
#ProcessModeling
#FailFast
#NoExceptionArchaeology
#ComposableSystems
#NativeFriendly
#GraalVM
#NoReflection
#DeterministicCode
#RefactorSafe
#SagaPattern
#UnixPhilosophy
#VanillaDI
#ModernJava
#ArchitectureMatters
🔧 El Saga Pattern gestiona transacciones distribuidas sin bloqueos en microservicios. Mantén consistencia cuando varios servicios intervienen. 💡
Lee más 👉 https://www.soloingenieria.org/ingenieria-de-software/saga-pattern/
#SagaPattern #Microservicios #IngenieríaDeSoftware #SistemasDistribuidos #Arquitectura
En microservicios, las transacciones ACID no escalan. El Saga Pattern ofrece consistencia eventual sin bloquear recursos. A veces, soltar el control absoluto es la mejor decisión arquitectónica. 🔧
#SagaPattern #Microservicios #IngenieríaDeSoftware #SistemasDistribuidos #Arquitectura