' oicbasics: Basic Error Handling in OIC | Oracle Integration Cloud
May 17, 2020

Basic Error Handling in OIC | Oracle Integration Cloud






Oracle Integration Cloud Service provides "Global Fault Handler" to catch errors/faults in orchestrated integration and perform actions. In an event of a fault in an integration it goes to "Global Fault Handler" to perform some user define actions like notifying about error by sending email notification etc. and then stops the flow of integration abruptly with an error state i.e. integration will stop and not move to next logical step. We can add fault handling to any integration type (for example: app driven orchestration, scheduled integration etc.). 

Now suppose 👀 →when you have to iterate through multiple conditions and need to continue even if one condition fails i.e. you don't want your integration flow to stop but move on to the next logical step. To achieve this we have to configure "Default Fault Handler" (at Scope Level).
Scope can catch the error and move ahead to the next logical step in the integration.This does not stop the integration abruptly but rather moves to the next logical step(ex. if there is any Loop, loop will continue to execute).



I hope the basic understanding about 'Global Fault Handler' and 'Scope Fault Handler' is clear. Now lets develop one integration capable of handling Error at Global as well as Scope level:


- Advertisement -


Use Case : 

We will see the steps to develop an App Driven Integration which will be capable to perform two mathematical operations,1st Addition of Two Numbers(example : Number_1 + Number_2) and 2nd Multiplication of multiple sets of two numbers( example : Number_1*Number_2 + Number_3 * Number_4 + Number_5*Number_6 + ... ).

We will configure Error Handler in such a way that if any Error Occur while doing Addition Operation, it will handled by Global Fault Handler and if any error occurred while doing Multiplication Operation it will handled by Scope Fault Handler.


Approach :
  1. First we will develop the Integration which will be capable to handle two mathematical operation - Addition and Multiplication as define in above Use Case.
  2. Then we will Add Error Handler in the Integration.
  3. Test the Integration.

Integration Flow overview which we will develop :


Sample Input & Output of the Integration which we are going to develop :

SoapUI Tool-5.5.0 Image

Sample Error Notification Email which we will receive if any Fault
occur in the Integration :



Lets see the integration development steps in detail :



- Advertisement -


Step 1: 
Create new App Driven Orchestration Integration.Give some meaningful name and then  click create.


Step 2:
Select REST Trigger connection.
(If you don't have any REST Trigger connection already configured, You can access this blog to configure one such REST connection)

Step 3 : 
Enter some meaningful name and click Next


   
  • Enter the below details and click Next - 
              *What is the endpoint's relative resource URI ? :  write  /add&Multiply 
             (you can give any meaning full word with "/" )       
          
            *What action do you want to perform on the endpoint ? : Select POST
                  and 
              Select Configure a request payload for this endpoint
                  Select Configure a response payload for this endpoint



  • Download below schema and upload the same as Request Payload Format and then click Next
         Click to Download Request Schema


- Advertisement -



  • Download below schema and upload the same as Response Payload Format and then click Next
         Click to Download Response Schema


  • Click Done.



- Advertisement -


Step 4 :
Add one Assign action. Inside this we will declare one variable to add mathematical logic of Addition operation.
  • Enter meaningful name and click Create
  • Click on '+' sign to add variable.
  • Click on edit option (pencil icon) to add addition expression.
  • Drag and drop the variable and create expression as shown in below image. [see below image for your reference]
  • Put both the variables inside INTEGER Function and then click Validate & Close.

  • Click Validate and close.

- Advertisement -



Step 5 : 
Similarly create one more Assign activity with some meaningful name. Inside this assign activity we will declare one variable for Multiplication use.

  • Now declare one Variable in this assign activity :
                *Variable Name : vTotalMultiplicationValue  (you can give any meaningful
                    name )
                 Value : 0.0
                  (take reference from below image)

  • After assigning value to variable, click Validate and Close it.



- Advertisement -


Step 6: 
Add For Each action and configure the below details and click Create:
                     
*Name : Enter any meaningful name
*Repeating Element :drag and drop the repeating element from source  tree i.e. < >Multiply element from request payload.                         

*Current Element Name : Enter any meaningful name. The current element can be used for activities within the For Each scope.



Step 7: Add Scope within For Each and give some meaningful name and click Create.
                      


- Advertisement -


Step 8: 
Now add one Assign activity within the scope in which we will configure mathematical
expression to perform multiplication of multiple sets of numbers.


  • Enter meaningful name and click Create.
  • Select the variable name 'vTotalMultiplicationValue' which we have declare before For Each action. 
  • Click Edit option ( pencil icon )
  • Build the Mathematical expression ( ex : Total=Total+ Number_1*Number_2 ) and putt all the three variables in Integer function as shown in below image. This expression will help to multiply all the sets of input numbers and then add them together to give final Output. After creating the expression click Validate & Click Close.
         (take reference from below image)

  • Click Validate and close.

- Advertisement -


Step 9: 
Now at last map the output of addition and total multiplication value. Open the mapper.


  • Map the $vAddition variable to output variable, TotalAddition

  • Then Assign Integer function (because output variable TotalAddition datatype is       Integer) as shown in below image.
  • Similarly map the $vTotalMultiplication to TotalMultiplication element and then      assign Integer Function.

  • Click Validate and Close the mapper.

- Advertisement -


Step 10: Now Enable the Tracking Variable by clicking on right hamburger sign.

  • Drag and drop any one element and click Save and Close.
Integration development to perform Addition and Multiplication operation completed.


Lets configure the "Scope Fault Handler" & "Global Fault Handler" in the integration.

#ScopeFaultHandler :


Step 1: 
Click on Fault Handler, available in Scope and then click Default Handler



  • Default Fault Handler flow window will open. Here we will configure email                  notification to send Scope Error Detail .

- Advertisement -


Step 2: Add Notification 



                 Enter meaningful name and click Create.




 Step 3 : Configure the Notification payload with below details :

                      *From : Enter the sender email details.
                      *To : Enter the receiver email address.
                      *Subject : Write 'Scope Error Notification' or you can give any meaningful subject

                     *Body : Download the below HTML code and paste the same 

                     Download HTML Code.




             Now lets assign value in each Parameter Name which we declared in above HTML 
            code.

  • Click on + icon and add parameter  ' InterfaceName ' and then click Edit to assign value     


- Advertisement -


                   Drag & drop the interface name and then click validate & close.

  • similarly add parameter "Error Message"  and then click Edit to assign Parameter Value
             
  • Drag & drop reason element from fault object and then click validate and Close
  • Last but not the least declare the third parameter "MessageFlowId" and drag and drop the FlowID function. Click validate & close.

                  
             Notification window configuration completed. Click Validate & Close it.


                
             Scope Fault handler added successfully.



#GlobalFaultHandler :

Step 1 :Click on Global Fault




- Advertisement -


Step 2 :Global Fault window will get open. search for Notification and add it.



                    Give some meaningful name and click create.



Step 3:  
Configure the notification payload similarly like scope Notification Payload which we configured above. (Step 3 Of #ScopeFaultHandler)


- Advertisement -



       once configuration completed, click Validate and Close.



Click Save and Close. Integration development completed and is ready to Test. Access the NEXT ARTICLE to TEST the Integration.

.


14 comments:

  1. Hi Kabir,

    Your blog is very nice for OIC stuff. I have multiple DB invokations in integration flow. how can I handle the DB related exception example, when DB went down. Thanks.

    ReplyDelete
    Replies
    1. it can be handled in Scope Error Handler specifically for DB Adapter Invocation. Based on the Error message you can have a condition check for DB Down Error and then you can handled it as per your requirement.

      Delete
  2. Hello Habir,

    I've Multible Integration and all of them without scope how can I hanle this case without recreate the integrations again?

    Thanks

    ReplyDelete
    Replies
    1. you can add scope anytime in the integration and then you can drag and drop MOST of the integration components (adapter,mapper) inside the scope.

      Delete
  3. I have a similar for each loop and iterating over a collection of records and invoking the rest api for each record. However i want to proceed with the the next iteration if we face an error, log the error we faced and proceed with the next set of records

    ReplyDelete
    Replies
    1. Inside Scope define the code to log the error, so whenever error comes it will move inside scope and log the error and the proceed with next iteration.

      If you still have problem to understand, Sumit you can contact me at 'thekabiryadav@outlook.com'

      Delete
    2. Yes, the logical thing was to create some activity (log or do something ) in the Manage Scope, and TEST, the whole idea suggested in the Post. But lazy me without being trying posted the query, I should have at least tried couple of times first and I apologize for that.

      It worked like a charm. Thank you so much for your detailed and very informative post and your quick response.

      Cheers!!

      Delete
  4. hello, in my integration I command multiple transactions, what I want is that when it finds an error, the same integration does not stop and continues with its flow
    Regards

    ReplyDelete
    Replies
    1. please read the blog properly, you will get the answer of your query....

      Delete
  5. Dear Kabir , If there is an error occurred in transaction and to retry the transaction Automatically not Manually.How can we achieve it is there any Retry action there .Please help me with your Inputs.

    ReplyDelete

If you have any doubts, Please let me know.

Top