This topic applies only to the IBM Business Process Manager Advanced configuration.

Compensating activities in a long-running process

In a long-running process, each transaction within it is committed individually. To set up compensation, you need to specify how to deal with each activity should it fail.

About this task

Before you can create a compensation for a process, you will need to identify a few things:
  • Compensation is tightly coupled with fault handling. You need to think about compensation when you are modelling fault handling.
  • The steps necessary to deal with it, and return the process to an equitable state.

Compensation using Compensation Handlers (BPEL)

About this task

To compensate the individual activities within a long-running process:

Procedure

  1. To begin, you will have to make this a long-running process. To do this, click an empty area of the canvas, click the Details tab in the properties area, and check the BPEL process type setting. If it is not set to Long-running, click the Refactor to link to make it Long-Running.
  2. Select either one of the following activities onto the canvas: invoke, scope, collaboration scope or human task. Use an invoke or human task if you will be creating a compensation handler for a single activity of this type, or use a scope or collaboration if you want to compensate the whole structured activity.
  3. Click this activity to launch the action bar.
  4. In the action bar, click the Add Compensation Handler icon as shown in this image. The compensate handler in the action bar This will create a handler (an empty box outlined in gray) beside the original activity.
  5. Populate this compensation handler with the activities needed to create the compensation logic.
  6. If a compensate activity itself is part of your compensation logic, you have two choices:
    1. the compensate activity should compensate everything that is included in your selected activity: (default, do nothing)
    2. the compensate activity should compensate a specific invoke, scope, collaboration scope or human task activity that is included in your selected activity, then you must specify that target activity in the Target Activity field in the Details tab for this compensate activity.

Results

If the process fails anytime after the invoke or scope activities have successfully been committed, then the associated compensation handler will be executed.
Note:
  • A compensation handler will only run if the activity with which it is associated has completely successfully.
  • You can also define undo actions for individual invoke activities in long-running processes in the same manner as you would assign a compensation to invoke activities within a microflow. See Compensating a microflow.

BPMN-style Compensation

About this task

Furthermore, you can also add compensate activities to generalized flow activities, in order to achieve a "BPMN-style" compensation. Compensate activities can be included in a generalized flow activity if and only if:
  • They do not have a Target Activity field specified in the Details tab for this compensate activity.
  • They are directly enclosed in a generalized flow activity. That generalized flow activity must either be:
    • Directly enclosed in the Process or a Scope activity.
    • Directly enclosed in a receive case branch of a Receive Choice activity, that Receive Choice activity, in turn, must also be directly enclosed by a process or scope.
If any of the listed conditions is violated, adding a compensate activity to a generalized flow will cause a validation error.

Results

The usage of compensate activities in generalized flow activities might be useful in combination with fault links. When a compensate activity in a generalized flow activity is activated, everything that has successfully completed in the GFlow until now and that has a compensation handler is compensated by this compensate activity.