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
- Log into the BPS Server Management Console.
- On the Main tab, under Processes, click Add.
- Upload the
<EI_HOME>/
samples/business-process/bpel/
FlightReservationProcess.zip
directory. - Under Processes, click List, and then click the process ID for FlightReservationProcess (CompensationProcess).
- 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
- In the WSDL details area, click Try It.
The TravelPlanService appears in a separate TryIt window. - In the TryIt window, click Send.
- 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.