Currently, the Invoke activity is the only activity that supports failure handling and recovery. The mechanism is identical for all other activities that may support failure handling and recovery in the future.
In case of the Invoke activity, a failure condition is triggered by the integration layer, in lieu of a response or fault message. The Invoke activity consults its failure handling policy (specified here) and decides how to respond.
Set faultOnFailure to yes, if you want the activity to throw a fault on failure. All other failure handling settings are ignored. The activity will throw the activityFailure fault.
The activityFailure fault is a standard fault, so you can use the exitOnStandardFault attribute to control whether the process exits immediately, or throws a fault in the enclosing scope.
Set retryFor to a positive integer if you want the activity to attempt self-recovery and retry up to that number of times. Set retryDelay to a reasonable time delay (specified in seconds) between retries. For example, if you set retryFor=2, retryDelay=30, the activity will retry after 30 and 60 seconds, for a total of three attempts, before entering activity recovery mode.
If the activity retries and succeeds, it will complete successfully as if no failure occurred. Of course, the activity may retry and fault, e.g. if the invoked service returns a fault. If the activity has exhausted all retry attempts, it enters activity recovery mode. By default retryFor is zero, and the activity enters recovery mode after the first failure.
When in recovery mode, you can recover the activity in one of three ways:
<ext:failureHandling xmlns:ext="http://ode.apache.org/activityRecovery"> <ext:faultOnFailure> _boolean_ </ext:faultOnFailure> <ext:retryFor> _integer_ </ext:retryFor> <ext:retryDelay> _integer_ </ext:retryDelay> </ext:failureHandling>The faultOnFailure, retryFor and retryDelay elements are optional. The default values are false for faultOnFailure, and zero for retryFor and retryDelay. An activity that does not specify failure handling using this extensibility element, inherits the failure handling policy of its parent activity, recursively up to the top-level activity of the process. You can use inheritance to specify the failure handling policy of a set of activities, or all activities in the process, using a single failureHandling extensibility element.
Note that due to this behavior, if activity S specifies failure handling with the values retryFor=2, retryDelay=60, and has a child activity R that specifies failure handling with the values retryFor=3, the retryDelay value for the child activity R is 0, and not 60. Using the failureHandling element without specifying one of its value elements will apply the default value for that element.
A simple invoke with the ext:failureHandling extension:
<bpel:invoke inputVariable="myRequest" operation="foo" outputVariable="aResponse" partnerLink="myPartner" portType="spt:SomePortType"> <ext:failureHandling xmlns:ext="http://ode.apache.org/activityRecovery"> <ext:faultOnFailure>false</ext:faultOnFailure> <ext:retryFor>2</ext:retryFor> <ext:retryDelay>60</ext:retryDelay> </ext:failureHandling> </bpel:invoke>
And a sequence activity that converts failures into faults:
<bpel:sequence> <ext:failureHandling xmlns:ext="http://ode.apache.org/activityRecovery"> <ext:faultOnFailure>true</ext:faultOnFailure> </ext:failureHandling> ... <bpel:invoke inputVariable="myRequest" operation="foo" outputVariable="aResponse" partnerLink="myPartner" portType="spt:SomePortType"> <bpel:catchAll> ... </bpel:catchAll> </bpel:invoke> </bpel:sequence>
The process instance management provides the following information: