Using Compensation After Undoing a Series of Operations

Compensation occurs when the BPEL process service component cannot complete a series of operations after some have completed, and the BPEL process service component must backtrack and undo the previously completed transactions. For example, if a BPEL process service component is designed to book a rental car, a hotel, and a flight, it may book the car and the hotel and then be unable to book a flight for the right day. In this case, the BPEL flow performs compensation by going back and unbooking the car and the hotel.

In a scope activity, the compensation handler can reverse previously completed process steps. The compensation handler can be invoked after successful completion of its associated scope with either of the following activities.

  • Compensate activity (in BPEL version 1.1 and 2.0 projects)

    This activity causes the compensation handler of all successfully completed and not yet compensated child scopes to be executed in default order.

  • compensateScope activity (in a BPEL version 2.0 project)

    This activity causes the compensation handler of one specific successfully completed scope to be executed.