So far, we implemented two <scope>
activities that model the book ordering process. However, to trigger <compensationHandler>
of the <scope>
activities, we need to have either <catch>
, <catchAll>
, <compensationHandler>
, or <terminationHandler>
. We will use <catchAll>
, and inside this, we will trigger <compensationHandler>
. To trigger <catchAll>
, we need to throw an explicit fault after the execution of the two scopes. Next, we learn how to throw this fault.
Carry out the following steps:
<sequence>
activity named throwFault
after the <scope>
activity named initiateCreditCardTransaction
. Then, drag-and-drop an <if>
activity within it and specify its condition, as shown in the following screenshot. This condition will check the content of inputVariable
and check whether it contains the compensate
value:<throw>
activity inside it, so if the content of inputVariable
contains the compensate
value, it triggers the <throw>
activity. Configure this activity to throw a fault named TriggerCompensationFault
, as follows:<else>
, add an <empty>
activity, so if the content of inputVariable
does not contain the compensate
value, the fault is not thrown. Then the <sequence>
named throwFault
looks like what is shown in the following screenshot:In the previous section, we throw a fault from the BPEL process if
inputVariable
contains a compensate
value. This fault is used to trigger the compensation of the created scopes.
In the previous section, we throw a fault from the BPEL process if
inputVariable
contains the compensate
value. Now we need to catch it and trigger <compensationHandler>
for the registerBookOrder
and initiateCreditCardTransaction
scopes. For this, we will add a <catchAll>
activity to catch the thrown fault and trigger <compensationHandler>
within the <catchAll>
activity in the next section.