Class SagaResult

java.lang.Object
org.acemq.amqp.patterns.SagaResult

public final class SagaResult extends Object
What a saga did.

Returned rather than thrown, because a failed saga is not an exceptional condition to a caller that has to decide what happens next — and because the interesting part is not the exception but unresolved(), the list of things that could not be undone.

  • Method Details

    • isComplete

      public boolean isComplete()
      Returns:
      whether every step ran
    • compensated

      public boolean compensated()
      Returns:
      whether a step failed and the earlier ones were undone
    • failedAt

      public Optional<String> failedAt()
      Returns:
      the step that failed, when one did
    • failure

      public Optional<RuntimeException> failure()
      Returns:
      why it failed
    • completed

      public List<String> completed()
      Returns:
      the steps that ran, in order, before the failure
    • unresolved

      public List<String> unresolved()
      The steps whose compensation failed.

      This is the list to alert on. Everything else a saga reports is recoverable by construction; these are real-world effects that happened, were meant to be undone, and were not. Nothing else in the system knows about them, and no retry will resolve them — a person has to.

      Returns:
      the steps a human now has to reconcile, in the order compensation was attempted
    • hasUnresolved

      public boolean hasUnresolved()
      Returns:
      whether anything was left in a state nobody intended
    • toString

      public String toString()
      Overrides:
      toString in class Object