# Saga (dapr-sdk-parent 1.12.2 API)
declaration: package: io.dapr.workflows.saga, class: Saga

Package io.dapr.workflows.saga

# Class Saga

java.lang.Object
io.dapr.workflows.saga.Saga

public final class Saga extends Object

## Constructor Summary

Constructors
Constructor
Description
`Saga(SagaOption option)`
Build up a Saga with its options.

## Method Summary

Modifier and Type
Method
Description
`void`
`compensate(WorkflowContext ctx)`
Compensate all registered activities.
`void`
`registerCompensation(String activityClassName, Object activityInput)`
Register a compensation activity.
`void`
`registerCompensation(String activityClassName, Object activityInput, com.microsoft.durabletask.TaskOptions taskOptions)`
Register a compensation activity.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### Saga

public Saga(SagaOption option)
Build up a Saga with its options.

Parameters:
  `option` - Saga option.

## Method Details

### registerCompensation

public void registerCompensation(String activityClassName, Object activityInput)
Register a compensation activity.

Parameters:
  `activityClassName` - name of the activity class
  `activityInput` - input of the activity to be compensated

### registerCompensation

public void registerCompensation(String activityClassName, Object activityInput, com.microsoft.durabletask.TaskOptions taskOptions)
Register a compensation activity.

Parameters:
  `activityClassName` - name of the activity class
  `activityInput` - input of the activity to be compensated
  `taskOptions` - task options to set retry strategy

### compensate

public void compensate(WorkflowContext ctx)
Compensate all registered activities.

Parameters:
  `ctx` - Workflow context.