Choose the appropriate compensation for your process

There are two ways in which you can compensate a business processes. Here are some suggestions on how to choose the one that is best for you.

The two options are:

Compensation pairs

Compensation pairs are the original properties of each of the individual parts of a business process. These properties are saved so that they can be restored if the process cannot be committed and must be rolled back. The original status of the activity is stored in an operation, and its value in a variable.

Compensation handler

A compensation handler is a series of isolated activities that are associated with an activity within a business process. The activities within such a handler will only run when a fault is thrown, and after the parent activity has already been committed. The goal of a compensation handler is to return a failed process to a balanced state.

This may be a very easy decision for you. In fact it may already be made for you. Keep the following critical points in mind:

So, if you are designing a long-running process, then you can use either of these options. If the compensation characteristics of each activity are fairly simple (in that compensation can be achieved in a single step), then consider using compensation pairs for each of these activities. If, however, you require compensation that makes use of more complicated logic, assign a compensation handler to each activity, and populate it with the necessary objects.


Example

To see an example of how to use compensation in a business process that you can build and run yourself, go to http://publib.boulder.ibm.com/bpcsamp/index.html, and click Advanced BPEL features > Compensation.

You will need a connection to the internet to view this example.

BPEL process editor

BPEL process compensation

Building BPEL processes


Related concepts:
Work with BPEL extensions
Best Practice: When to not use the BPEL extensions


Related reference:
Compensation tab: BPEL process editor