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 execute 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:
- If you do not have IBM extensions enabled for this process, then you CANNOT
USE compensation pairs and MUST use a compensation handler. The compensation
tab in the process editor is an IBM enhancement of the BPEL programming language,
and so will not be available if this option was disabled when the process
was initially created.
- You cannot use a compensation handler with a microflow. Since microflows
execute within a single transaction, you must use the compensation tab of
the process editor to store the original properties of each invoke activity
in the event that the process fails.
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.