What Happens When You Create a While Activity
The code that follows provides an example of the .bpel file after design completion. The while activity includes a scope activity. The scope activity includes sequence and fault handlers at the top level. The sequence includes invoke and assign activities and fault handlers that define a catchAll containing assign and wait activities wrapped in a sequence.
The following code calls an external service. If the external service throws a fault, the fault handler catches the fault and increments the dbStatus variable value.
Therefore, the exit condition of the while loop is either of the following:
-
There is no exception, upon which the
dbStatusvalue is set to a value of10, which results in the while condition evaluating to false. -
After throwing a fault five times, the
dbStatusvalue is5, and the while condition returns false.
<while name="While_1" condition="bpws:getVariableData('dbStatus') > 5">
<scope name="Scope_1">
<faultHandlers>
<catchAll>
<sequence name="Sequence_2">
<assign name="assign_DB_retry">
<copy>
<from expression="bpws:getVariableData('dbStatus') + 1"/>
<to variable="dbStatus"/>
</copy>
</assign>
<wait name="Wait_30_sec" for="'PT31S'"/>
</sequence>
</catchAll>
</faultHandlers>
<sequence name="Sequence_1">
<invoke name="Write_DBWrite" partnerLink="WriteDBRecord"
portType="ns2:WriteDBRecord_ptt" operation="insert"
inputVariable="Invoke_DBWrite_merge_InputVariable"/>
<assign name="Assign_dbComplete">
<copy>
<from expression="'10'"/>
<to variable="dbStatus"/>
</copy>
</assign>
</sequence>
</scope>
</while>Note:
The while activity code fragment in the preceding example uses a BPEL 1.1 construct of bpws:getVariableData('dbStatus'). For BPEL 2.0, variables are referenced directly using $ sign and dot (.) notation. For example:
<while name="While1"> <condition>$inputVariable.payload/client:counter > 0 </condition>