(WID/WPS) Fault Links

When faults occur in our business process, fault handlers are typically engaged to deal with the fault. The generalized flow activity offers a simplified fault handling procedure. 
From any scope or basic activity (excluding the Throw and Rethrow activities) we can add one or more "fault links". 


A fault link in an activity is followed if the specified fault occurs while the activity is running. We can define "catch" fault links for various conditions, or we can create a "catch all" fault link, which will be followed should any fault occur that is not covered by a catch fault link. If multiple fault links are modeled for the same activity, best match decides which fault link will be followed. The fault catching rules are the same as for fault handlers.


Fault link considerations:


When we use fault links in our business process, consider the following: 
  • A fault link is activated for faults that occur within the source activity only. The evaluation of conditions of normal links is not part of the execution of the activity. 
  • If the source activity of the fault link is a scope activity, the fault handler of the scope activity is evaluated first when a fault occurs inside the scope. However, the fault handler can rethrow the fault. In this case, a fault link of the scope can catch the fault and can be navigated. 
  • If an activity is the source of multiple fault links, only one of the fault links can be navigated when a fault occurs. 
  • The target activity of the fault link will be executed normally. Compensate and rethrow activities in fault handlers cannot be the target of a fault link. 
  • When a fault contains fault data, a variable of the fault data type needs to be declared on the surrounding scope. The fault link must reference this variable so that the target activity of the fault link has access to the fault data. 
Following business process shows the fault link usage along with fault handler.


FaultBO used for the fault :


Interface used for Invoke activity :


When invoke activity throws any fault say fault1, Fault handler enclosed with the activity will try to handle this fault first. When it is rethrown from fault handler it will be following the corresponding fault link path defined on the scope level.


Code snippet for throwing a fault {Invoke activity implementation}:
private DataObject createFault(String severity, String messageID, String message, String shortText)
{
BOFactory bof =(BOFactory)ServiceManager.INSTANCE.locateService ("com/ibm/websphere/bo/BOFactory");
DataObject faultBo = bof.create("http://FaultLinkModule", "FaultBO");
faultBo.setString("severity", severity);
faultBo.setString("messageID", messageID);
faultBo.setString("message", message);
faultBo.setString("shortText", shortText);
return faultBo;
}


public Boolean doValidation(String input) {
boolean value=true;
if(<<Condition1>>)
{
value=false;
throw new MyServiceBusinessException(createFault("1", "111", "This is Fault 1", "FAULT1"),"fault1");
//throw new MyServiceBusinessException(new String("Fault 1 Thrown"), "fault1");//Fault Name : fault1
}
else if(<<Condition2>>)
{
value=false;
throw new MyServiceBusinessException(createFault("2", "222", "This is Fault 2", "FAULT2"),"fault2");//Fault Name : fault2
//throw new MyServiceBusinessException(new String("Fault 2 Thrown"), "fault2");
}
return value;
}

//Where MyServiceBusinessException is a user defined class extending ServiceBusinessException class.


Download the PI: https://docs.google.com/open?id=0ByotHxAO08TDQWtJbjBDaTNSdTJYaEZEV3ZaVFA1UQ

Note :


No comments:

Post a Comment