Compensation handlers let you create business process logic to undo or otherwise compensate for completed logic occurring within a complex activity in a business process service that has encountered some exception. A complex activity can contain only one compensation handler.
A compensation handler can be invoked only if the complex activity has completed normally. Compensation handlers are invoked either implicitly or explicitly. A compensation handler or handlers are explicitly invoked if a fault handler or another compensation handler contains a compensate activity. The compensate activity can be used to invoke a compensation handler on all inner complex activities that are direct children. Alternately, the compensate activity can be used to explicitly invoke the compensation handler on any single complex activity that is a descendent.
Compensation handlers are implicitly invoked if the complex activity encounters an unhandled exception. In this case compensation handlers are invoked on all complex activities that are direct children. Invocation of a compensation handler on a complex activity that does not have a compensation handler defined results in the implicit invocation of the compensate call on that complex activity.
Compensation handlers are invoked in the reverse order of how the complex activities completed. A compensation handler contains a snapshot of the variables within its scope at the time the complex activity completed. The compensation handler of a specific complex activity is invoked for each successful completion of the complex activity.
Send your feedback on this help topic to Sybase Tech Pubs: pubs@sybase.com