May 17, 2020

Basic Error Handling in OIC



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:


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 :


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


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


  • Click Done.


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.

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.


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.
                      

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.

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.

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 .

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     

                   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



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)



       once configuration completed, click Validate and Close.


      Click Save and Close. Integration development completed and is ready to Test.

      Access the NEXT blog to Test the Integration.