Skip to main content

<compensationhandlers>

Provide compensation handlers, each of which performs a sequence of activities to undo a previous action.

Syntax

<scope>
   <throw fault='"BuyersRegret"'/>
   <faulthandlers>
     <catch fault='"BuyersRegret"'>
       <compensate target="RestoreBalance"/>
     </catch>
   </faulthandlers>
   <compensationhandlers>
     <compensationhandler name="RestoreBalance">
       <assign property='context.MyBalance' value='context.MyBalance+1'/>
     </compensationhandler>
   </compensationhandlers>
 </scope>

Elements

Element Purpose
<compensationhandler> Zero or more <compensationhandler> elements may appear inside the <compensationhandlers> container. Each <compensationhandler> element contains a specific sequence of BPL activities that undo a previous action.

Description

In business process management, it is often necessary to reverse some segment of logic. This convention is known as “compensation.” The ruling principle is that if the business process does something, it must be able to undo it. That is, if a failure occurs, the business process must be able to compensate by undoing the action that failed. You need to be able to unroll all of the actions from that failure point back to the beginning, as if the problem action never occurred. BPL enables this with a mechanism called a compensation handler.

BPL <compensationhandler> blocks are somewhat like subroutines, but they do not provide a generalized subroutine mechanism. You can “call” them, but only from <faulthandler> blocks, and only within the same <scope> as the <compensationhandler> block. The <compensate> element invokes a <compensationhandler> block by specifying its name as a target. Extra quotes are not needed for this syntax:

<compensate target="general"/>

Compensation handlers are only useful if you can undo the actions already performed. For example, if you transfer money into the wrong account, you can transfer it back again, but there are some actions that cannot be neatly undone. You must plan compensation handlers accordingly, and also organize them according to how far you want to roll things back.

For details, see “BPL Error Handling Conventions” in Developing BPL Processes.

Note:

It is not possible to reverse the order of <compensationhandlers> and <faulthandlers>. If both blocks are provided, <compensationhandlers> must appear first and <faulthandlers> second.

<compensationhandler> Attributes and Elements

Attribute or Element Description
name, disabled, xpos, ypos, xend, yend attribute See “Common Attributes and Elements.”
<annotation> element

See Also

<catch>, <catchall>, <compensate>, <faulthandlers>, <scope>, and <throw>.

FeedbackOpens in a new tab