This site contains the documentation that is relevant to older WSO2 product versions and offerings.
For the latest WSO2 documentation, visit https://wso2.com/documentation/.

Compensation Handling

Compensation refers to reversing the effects of a service invocation when a failure occurs. Compensation handling is the act of undoing any actions that were performed by a successfully completed compensatable activity because of an exception that occurred elsewhere in a workflow. This sample demonstrates compensation handling when booking a hotel, car, and airline ticket. If the airline ticket fails, the hotel and car bookings should be cancelled by calling the appropriate compensation handlers.

Setting up the sample

  1. Log into the BPS Server Management Console.
  2. On the Main tab, under Processes, click Add.
  3. Upload the FlightReservationProcess.zip file found in the BPS_Home/repository/samples/bpel directory. (Samples are also located at our sample repository).
  4. Under Processes, click List, and then click the process ID for FlightReservationProcess (CompensationProcess).
  5. Scroll down to see the process visualization.

You can see in the TravelPlanProcess flow that the sequence first books the car, then the hotel, and then the flight. If the flight booking fails, the fault handler calls the compensation handlers for the hotel and car.

Running the sample

  1. In the WSDL details area, click Try It.
    The TravelPlanService appears in a separate TryIt window.
  2. In the TryIt window, click Send.
  3. In the Management Console, under Business Processes click Instances.

The CompensationProcess instance should now be listed. You can click the instance ID to see its details, including its variable values and activity.