Showing posts with label Error handling. Show all posts
Showing posts with label Error handling. Show all posts

Friday, August 9, 2013

Modelling osb error handling for synchronous services


Recently one of the queries I got was regarding the OSB error handling, how errors should be handled. The error handling will differ based on the communication pattern, whether the call is synchronous or asynchronous.
If the services are modeled to be synchronous it will be always useful to return a consistent error structure with a minimum of the error occurring service information, unique id w.r.t message so as to track it, unique error code, summary/details of the error. This needs to be defined properly and laid out before we start on a project. If the services are more asynchronous in nature, then it makes sense to have a common Error logging/handling/auditing framework which will receive the errors and based on any business rules can persist /notify the errors. In both approaches it is mandatory to define the Error message structure. The asynchronous can have more information whereas synchronous can be a subset of this since the caller or consumer need not be given a lot of unnecessary information related to error. The synchronous response should be more formatted to be humanly readable and no stack trace.
  In case of OSB there can be multiple proxies and you will need to control the response message flow and track it. Instead of having multiple reply points from error catch blocks it will be better to have multiple catch blocks which will Raise an Error with the error payload populated into the body. The Global catch block will do a reply with success to the caller Proxy with the body


OSB Implementation
The different stages in OSB should be segregated and defined properly. And each stage should be having Error Handler-catch block. In each catch block

Catch the error globally and Reply with success
An error should contain minimum of below listed information so that it helps in identifying/tracking the error.
ResponseStatus: "-1"
ErrorSource: Atomic service
MessageDate: "2013-08-08T15:48:13.013-07:00",
ServiceName: "Validation Service",
OperationName: ": validateRequest",
Code: "VALIDATION_ERROR-ERR103",
Summary: "Validation Failure ",
Details: "BEA-382515: oops!!! Duplicate Request Signature",
SeverityLevel: "1"

If we are having a Gateway architecture then we can evaluate the error response at the gateway, see the error code and based on that can work out appropriate error handling mechanisms.

Monday, February 18, 2013

Error handling using EDN-reuse code -Soa 11g


In my project we had used EDN event delivery network in SOA 11g for error handling.
We created an Error event and with a error message structure .
Eg: HelloPlatformErrorEvent, so I will be listing down the entries that you will need to implement error handling across the processes .The code is reusable and will take care skeletal common error handling.
The good thing with using EDN in errorhandling is we can have multiple consumers consuming the event and do different processing. Since EDN is fully supported in SOA 11g , the overheads of publish and subscribe /configurations will not be bothering us. We need to create an event and consumers can receive events .So if we can have multiple consumer bpel’s each doing different functionality ,one can write a file,one process writing to DB, once sending notifications. So we have plugged out the error handling/logging mechanism out of the processes. Consumers can be enables/disabled separately based on requirement.

Steps for reusing the event driven error event codes

Here for example the
event  :  HelloPlatformErrorEvent,
edl file : HelloPlatformErrorEvent
Message structure :HelloPlatformErrorEvent.xsd
Since it’s used across composites, the file will uploaded/accessed from MDS.

Composite.xml

·         Add to imports

<import namespace="http://schemas.oracle.com/events/edl/HelloPlatformErrorEvent"
          location="oramds:/apps/HelloPlatform/Events/edl/HelloPlatformErrorEvent.edl"
          importType="edl"/>

·         Add to component (bpel)
    <business-events>
      <publishes xmlns:pub1="http://schemas.oracle.com/events/edl/HelloPlatformErrorEvent"
                 name="pub1:HelloPlatformErrorEventMessage"/>
    </business-events>

. bpel file

·         Add to namespaces
         xmlns:bperrmsg="http://xmlns.oracle.com/HelloPlatform/ErrorMessage/V1"
         xmlns:errorEvent="http://schemas.oracle.com/events/edl/HelloPlatformErrorEvent"
·         Add to imports
<import namespace="http://xmlns.oracle.com/HelloPlatform/ErrorMessage/V1"
          location="oramds:/apps/HelloPlatform/Events/schema/HelloPlatformErrorEvent.xsd"
          importType="http://www.w3.org/2001/XMLSchema"/>

·          Add to Variables
<variable name="PublishHelloPlatformErrorEvent"
              element="bperrmsg:HelloPlatformErrorEventMessage"/>
·         Add inside catchall
The assign values will vary based on your message structure
       
<sequence name="ErrorSequence">
  <assign name="assignErrorEvent">
          <copy>
            <from>ora:getFaultName()</from>
            <to>$PublishHelloPlatformErrorEvent/bperrmsg:ErrorDetails/bperrmsg:ErrorCode</to>
          </copy>
          <copy>
            <from>ora:getConversationId()</from>
            <to>$PublishHelloPlatformErrorEvent/bperrmsg:InstanceDetails/bperrmsg:ConversationId</to>
          </copy>
          <copy>
            <from>ora:getInstanceId()</from>
            <to>$PublishHelloPlatformErrorEvent/bperrmsg:InstanceDetails/bperrmsg:InstanceId</to>
          </copy>
          <copy>
            <from>ora:getCompositeName()</from>
            <to>$PublishHelloPlatformErrorEvent/bperrmsg:InstanceDetails/bperrmsg:CompositeName</to>
          </copy>
          <copy>
            <from>ora:getProcessId()</from>
            <to>$PublishHelloPlatformErrorEvent/bperrmsg:InstanceDetails/bperrmsg:ProcessName</to>
          </copy>
          <copy>
            <from>ora:getFaultAsString()</from>
            <to>$PublishHelloPlatformErrorEvent/bperrmsg:ErrorDetails/bperrmsg:ErrorText</to>
          </copy>
          <copy>
            <from>'Error occured in TaskExecutionFetchPendingTasksProcess'</from>
            <to>$PublishHelloPlatformErrorEvent/bperrmsg:ErrorDetails/bperrmsg:ErrorMessage</to>
          </copy>
          <copy>
            <from>true()</from>
            <to>$PublishHelloPlatformErrorEvent/bperrmsg:ErrorHandlerOptions/bperrmsg:PersistMsgOnDB</to>
          </copy>
          <copy>
            <from>true()</from>
            <to>$PublishHelloPlatformErrorEvent/bperrmsg:ErrorHandlerOptions/bperrmsg:SendNotification</to>
          </copy>
        </assign>       
<invoke name="invokePublishHelloPlatformErrorEvent"
                bpelx:eventName="errorEvent:HelloPlatformErrorEventMessage"
                inputVariable="PublishHelloPlatformErrorEvent"
                bpelx:invokeAsDetail="no"/>
        <exit name="ProcessExit"/>
      </sequence>
   
That’s it for today. Thanks to Ram,Ravi for the coming up this model.