Fault Handling and Concurrency
Forum topic: Submitted by dougsleite on 28. August 2008 - 0:56.
Consider the following code excerpt:
...
<scope name="TravelAgencyBooking">
...
<faultHandlers>
<catch faultName="h:UnavailableHotelException">
<!-- Do something -->
</catch>
<catch faultName="f:UnavailableFlightException">
<!-- Do something -->
</catch>
</faultHandlers>
...
<sequence>
<!-- Make a concurrent invocation to Hotel and Flight -->
<flow>
<sequence>
<!-- Async invoke of the Hotel web service and wait for the callback -->
<invoke partnerLink="HotelWS"
portType="h:HotelAvailabilityPT"
operation="CheckHotelAvailability"
inputVariable="HotelDetails" />
<receive partnerLink="HotelWS"
portType="h:HotelCallbackPT"
operation="HotelAvailabilityCallback"
variable="HotelResponse" />
</sequence>
<sequence>
<!-- Async invoke of the Flight web service and wait for the callback -->
<invoke partnerLink="FlightWS"
portType="f:FlightAvailabilityPT"
operation="CheckFlightAvailability"
inputVariable="FlightDetails" />
<receive partnerLink="FlightWS"
portType="f:FlightCallbackPT"
operation="FlightAvailabilityCallback"
variable="FlightResponse" />
</sequence>
</flow>
<!-- Do something -->
</sequence>
</scope>
...
Consider that the operations CheckHotelAvailability and CheckFlightAvailability throw, respectively, an UnavailableHotelException and UnavailableFlightException.
As we can see, the two operations are invoked concurrently. Because of that, we can have a situation where both exceptions are thrown at the same time. In that case, what would happen? Would both fault handlers be executed, or just one would be chosen?
Moreover, is it possible to call a specific fault handler within another one?
Thanks in advance,
Douglas Leite
...
<scope name="TravelAgencyBooking">
...
<faultHandlers>
<catch faultName="h:UnavailableHotelException">
<!-- Do something -->
</catch>
<catch faultName="f:UnavailableFlightException">
<!-- Do something -->
</catch>
</faultHandlers>
...
<sequence>
<!-- Make a concurrent invocation to Hotel and Flight -->
<flow>
<sequence>
<!-- Async invoke of the Hotel web service and wait for the callback -->
<invoke partnerLink="HotelWS"
portType="h:HotelAvailabilityPT"
operation="CheckHotelAvailability"
inputVariable="HotelDetails" />
<receive partnerLink="HotelWS"
portType="h:HotelCallbackPT"
operation="HotelAvailabilityCallback"
variable="HotelResponse" />
</sequence>
<sequence>
<!-- Async invoke of the Flight web service and wait for the callback -->
<invoke partnerLink="FlightWS"
portType="f:FlightAvailabilityPT"
operation="CheckFlightAvailability"
inputVariable="FlightDetails" />
<receive partnerLink="FlightWS"
portType="f:FlightCallbackPT"
operation="FlightAvailabilityCallback"
variable="FlightResponse" />
</sequence>
</flow>
<!-- Do something -->
</sequence>
</scope>
...
Consider that the operations CheckHotelAvailability and CheckFlightAvailability throw, respectively, an UnavailableHotelException and UnavailableFlightException.
As we can see, the two operations are invoked concurrently. Because of that, we can have a situation where both exceptions are thrown at the same time. In that case, what would happen? Would both fault handlers be executed, or just one would be chosen?
Moreover, is it possible to call a specific fault handler within another one?
Thanks in advance,
Douglas Leite
Not exactly specified
The specification states on page 131:
If the scope faults before completion, then the appropriate fault handler gets control and all other fault handlers and termination handlers are uninstalled. A WS-BPEL processor MUST NOT run more than one explicit or default FCT-handler for the same scope under any circumstances.That said, I understand that the exact behavior is not specified. I would consider (nondeterministically) choosing one fault and discarding all others as compliant. I modeled it this way in the Petri net formalization of WS-BPEL 2.0 (see http://wwwteo.informatik.uni-rostock.de/ls_tpp/publications/Lohmann_2007...).
In an implementation, time stamps, names or anything else might be used to give one fault the preference over the others.
Best regards,
Niels