Partager via


Using the CompensatableTransactionScopeActivity Activity

The CompensatableTransactionScopeActivity activity is a compensatable version of the TransactionScopeActivity activity. CompensatableTransactionScopeActivity implements the ICompensatableActivity interface.

The CompensatableTransactionScopeActivity activity is useful for generating sagas, or multi-part work in which each piece is a transaction that, if any part fails, should be undone. Note that the work is undone rather than transactionally rolled back in a saga because any number of pieces of work could have committed successfully before the error occurred.

For example, in a scenario in which a travel agent needs to book flights, hotels, and cars as part of a vacation package, each activity that books reservations would be placed within a CompensatableTransactionScopeActivity activity. During execution, if a hotel and a flight were successfully booked, but an exception was encountered when booking the car reservation, it might make sense to undo the reservations for the flight and hotel. This cancellation functionality would be placed inside the CompensatableTransactionScopeActivity activity's corresponding CompensationHandlerActivity activity.

For information about the behavior of a TransactionScopeActivity activity, see Using the TransactionScopeActivity Activity.

For information about compensation, see Using the CompensateActivity Activity and Using the CompensationHandlerActivity Activity.

For a code sample that demonstrates how to use compensation, see Compensation Sample.

See Also

Reference

TransactionScopeActivity
CompensateActivity
CompensationHandlerActivity
ICompensatableActivity
CompensatableSequenceActivity
CompensatableTransactionScopeActivity

Concepts

Using the TransactionScopeActivity Activity
Using Compensation in Workflows
Using the CompensateActivity Activity
Using the CompensationHandlerActivity Activity
Using the CompensatableSequenceActivity Activity
Compensation Overview

Other Resources

Compensation Sample
Windows Workflow Foundation Activities