Skip to content

Using Compensation Handlers

A compensation handler is a container that holds the activities to perform the rollback. The handlers can be associated with a Scope or Invoke activity.

To add a compensation handler:

  1. Right-click the Scope or Invoke element and choose Add Compensation Handler. A sequence containing a compensate and rethrow activity displays.

    The contents of the compensation handler depend on your application logic.

  2. Configure the properties of each activity. You need to invoke the handler with either a Compensate activity or a Compensate Scope.

compensation diagram

Compensation handling is associated with a scope. You can think of a scope as a logical unit of work that contains activities that might need to be reversed or retried, while other parts of the process continue as expected. You define a compensation handler for a single scope and, while the compensation handler can only have a single child activity, this activity can be a structured activity, like a Sequence, which has its own child activities.

You can associate a compensate handler with an Invoke activity by including it within a Scope.


More Information