Package org.acemq.amqp.patterns
Class Saga.Builder<T>
java.lang.Object
org.acemq.amqp.patterns.Saga.Builder<T>
Collects the steps of a
Saga.-
Method Summary
Modifier and TypeMethodDescriptionbuild()compensateWith(Consumer<T> compensation) Gives the most recently added step something that undoes it.Adds a step with no compensation.
-
Method Details
-
step
Adds a step with no compensation.Legitimate for a step that changed nothing, and a mistake for one that did. There is no warning for the second case, because a library cannot tell them apart — which is the argument for writing the compensation first and the action second.
- Parameters:
stepName- what the step is calledaction- the work- Returns:
- this builder
-
compensateWith
Gives the most recently added step something that undoes it.- Parameters:
compensation- how to undo the last step- Returns:
- this builder
-
build
- Returns:
- the saga
- Throws:
IllegalStateException- if it has no steps
-