IBM BPM, V8.0.1, All platforms > Authoring services in Integration Designer > Developing business processes > Building BPEL processes > Defining BPEL process logic > Dealing with faults in your process

BPEL process compensation

Compensation is just another execution path of a process; it is coupled to fault handling in order to redress the operations that have already taken place.

Compensation has at times been described as a means of undoing an action, but this isn't necessarily accurate. More specifically, it is a service that is executed when a state is reached in your process that you have deemed to be undesirable. The goal is not always to return to a previous condition, but instead it is to maintain a balanced and consistent state and to compensate for any committed operations that conflict with this state.

Compensation logic is incompatible with Process Migration Specifications. If you hope to move running instances of a process to the latest version in your runtime environment, you should not use compensation logic in your process. See the related topic on Creating a new version of your process for more information.

There are two types of compensation: business compensation which occurs outside of a transaction, and technical compensation that occurs within.


Business compensation


Technical compensation


Choose the appropriate compensation for your business process

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

The two options are:

Compensation pairs

Each operation called by a process (invoke activity) is associated with an undo-operation that reverses the effects of the first operation. These two operations are called a compensation pair. Compensation pairs are typically used in microflows or technical compensation, but can also be part of long-running processes.

Compensation handler

A compensation handler is a series of isolated activities that are associated with an activity within a BPEL 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, asign 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 BPEL 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.

Dealing with faults in your BPEL process


Related concepts:
Fault activities
Raising faults


Related tasks:
Use fault handlers
Continue processing upon unhandled faults
Typing fault variables
Create a version of your business state machine