Define a compensation handler for a scope. The compensation handler can only have a single child activity, but this activity can be a structured activity like a sequence that has child activities. The contents of the compensation handler depend on your application logic.
Use a compensate activity within a fault handler, compensation handler, or termination handler to specify compensation on all inner scopes that have already completed successfully, in default order.
Use a compensate scope activity within a fault handler, compensation handler, or termination handler to specify compensation for a named, inner scope. This method provides control over the order and selection of compensation activities in a scope.
The following illustration compares default and specified compensation.
In the case where a scope does not define a compensation handler, the execution engine provides an implicit compensation handler. This handler contains a single
activity at compensates all of the enclosed scopes that have completed and are eligible for compensation. In general, you should only provide a compensation handler when you have some application-specific logic to execute in order to undo some previously executed logic.