Class AnnotationSagaWorkflow

java.lang.Object
org.j7m.middleware.examples.annotation.AnnotationSagaWorkflow

@SagaDefinition(name="annotation-invoice-saga") public final class AnnotationSagaWorkflow extends Object
Descriptor-backed saga workflow example.

The saga annotations are descriptor metadata in this Phase 6.11 slice. Durable execution, retries, and recovery remain owned by SagaService. The example manually executes the steps and compensation so readers can see the intended order without claiming a new transaction coordinator.

  • Constructor Details

    • AnnotationSagaWorkflow

      @Inject public AnnotationSagaWorkflow(@J7mResource("annotation-saga") org.j7m.middleware.api.saga.SagaService sagaService, @CurrentInvocation org.j7m.middleware.application.api.InvocationContext invocationContext, AnnotationExampleAudit audit)
      Creates a workflow with the public saga service capability.
      Parameters:
      sagaService - injected public saga service
      invocationContext - current invocation context
      audit - safe audit collector
  • Method Details

    • reserve

      @SagaStep(name="reserve", order=0) public String reserve(String invoiceId)
      Reserves an invoice.
      Parameters:
      invoiceId - invoice id
      Returns:
      step result
    • charge

      @SagaStep(name="charge", order=1) public String charge(String invoiceId, boolean fail)
      Charges an invoice.
      Parameters:
      invoiceId - invoice id
      fail - whether to simulate failure
      Returns:
      step result
    • releaseReserve

      @Compensation(step="reserve") public String releaseReserve(String invoiceId)
      Compensates the reserve step.
      Parameters:
      invoiceId - invoice id
      Returns:
      compensation result
    • deadLetter

      @DeadLetterHandler public String deadLetter(String invoiceId)
      Handles failed workflow data through a safe dead-letter summary.
      Parameters:
      invoiceId - invoice id
      Returns:
      safe dead-letter text
    • runScenario

      public List<String> runScenario(String invoiceId, boolean failCharge)
      Runs a deterministic local scenario that demonstrates step and compensation order.
      Parameters:
      invoiceId - invoice id
      failCharge - whether to fail charge
      Returns:
      ordered events