20162

How Can I handle Error sequence in WSO2ESB

Question:

i want handle error using fault sequence but i wish to customize it with delete operation my scenario is while i am inserting in 2 tables if error occurred in 2nd table insertion i need to delete 1 st row insertion also my config is below

<proxy xmlns="http://ws.apache.org/ns/synapse" name="ErrorHandling" transports="https,http" statistics="disable" trace="disable" startOnLoad="true"> <target > <inSequence onError="fault"> <property name="eno" expression="//eno/text()" scope="default" type="STRING"/> <property name="ename" expression="//ename/text()" scope="default" type="STRING"/> <property name="esal" expression="//esal/text()" scope="default" type="STRING"/> <property name="deptname" expression="//deptname/text()" scope="default" type="STRING"/> <property name="deptid" expression="//deptid/text()" scope="default" type="STRING"/> <payloadFactory> <format> <p:insert_emp_operation xmlns:p="http://ws.wso2.org/dataservice"> <xs:eno xmlns:xs="http://ws.wso2.org/dataservice">$1</xs:eno> <xs:ename xmlns:xs="http://ws.wso2.org/dataservice">$2</xs:ename> <xs:esal xmlns:xs="http://ws.wso2.org/dataservice">$3</xs:esal> </p:insert_emp_operation> </format> <args> <arg expression="get-property('eno')"/> <arg expression="get-property('ename')"/> <arg expression="get-property('esal')"/> </args> </payloadFactory> <send receive="Error_Seq"> <endpoint> <address uri="http://localhost:9764/services/emp_DataService/" format="soap11"/> </endpoint> </send> <log level="full"/> </inSequence> <outSequence onError="fault"> <send/> <log level="full"/> </outSequence> </target> <description></description> </proxy>

and sequence is like this

<sequence xmlns="http://ws.apache.org/ns/synapse" name="Error_Seq" onError="fault"> <property xmlns:f="http://ws.wso2.org/dataservice" xmlns:ns="http://org.apache.synapse/xsd" name="ID" expression="//f:ID/text()" scope="default" type="STRING"/> <log> <property xmlns:ns="http://org.apache.synapse/xsd" name="faisal" expression="get-property('ID')"/> </log> <payloadFactory> <format> <p:insert_dept_operation xmlns:p="http://ws.wso2.org/dataservice"> <xs:deptno xmlns:xs="http://ws.wso2.org/dataservice">$1</xs:deptno> <xs:deptname xmlns:xs="http://ws.wso2.org/dataservice">$2</xs:deptname> <xs:deptid xmlns:xs="http://ws.wso2.org/dataservice">$3</xs:deptid> </p:insert_dept_operation> </format> <args> <arg xmlns:ns="http://org.apache.synapse/xsd" expression="get-property('ID')"/> <arg xmlns:ns="http://org.apache.synapse/xsd" expression="get-property('deptname')"/> <arg xmlns:ns="http://org.apache.synapse/xsd" expression="get-property('deptid')"/> </args> </payloadFactory> <send> <endpoint> <address uri="http://localhost:9764/services/dept_DataService/" format="soap11"/> </endpoint> </send> </sequence>

fault sequenceis like this

<sequence xmlns="http://ws.apache.org/ns/synapse" name="fault"> <property xmlns:ns="http://org.apache.synapse/xsd" name="ID" expression="get-property('ID')" scope="default" type="STRING"/> <log level="full"> <property name="MESSAGE" value="Executing default 'fault' sequence"/> <property xmlns:ns="http://org.apache.synapse/xsd" name="ERROR_CODE" expression="get-property('ERROR_CODE')"/> <property xmlns:ns="http://org.apache.synapse/xsd" name="ERROR_MESSAGE" expression="get-property('ERROR_MESSAGE')"/> <property xmlns:ns="http://org.apache.synapse/xsd" name="Property" expression="get-property('ID')"/> </log> <payloadFactory> <format> <p:Delete_Op xmlns:p="http://ws.wso2.org/dataservice"> <xs:eno xmlns:xs="http://ws.wso2.org/dataservice">$1</xs:eno> </p:Delete_Op> </format> </payloadFactory> <send> <endpoint> <address uri="http://localhost:9764/services/dept_DataService/" format="soap11"/> </endpoint> </send> </sequence>

but its not working its working while the DSS Is in OFF mode let me know when DSS is In Running mode how to delete the 1st table row

Answer1:

In your scenario when update fails at DSS, it will send back a SOAP fault to the ESB. Since ESB this is still just another message response, and it will not goto the fault sequence, unless you explicitly check the message and do the necessary actions. So you have to declare comming message is a SOAP_FAULT so you hace to say it is a SOAP_FAULT and force it to error sequance. This is explained in [1].

[1] <a href="http://maharachchi.blogspot.com/2012/09/now-you-can-send-soapfaults-to-fault.html" rel="nofollow">http://maharachchi.blogspot.com/2012/09/now-you-can-send-soapfaults-to-fault.html</a>

Recommend

  • Deleting duplicates rows from oracle
  • how to give action in java script for get method using jsp values
  • Enrich mediator Invalid Object type to be inserted into message body
  • WSO2 ESB: XML response in WSO2 REST API call not parsed
  • WSO2 ESB - REST API - Response Does Not Come
  • MethodHandler in Hibernate using ByteBuddy proxies gets stuck in endless loop
  • SQL Server 2005 Index rebuild when increasing the size of a varchar field
  • How to get all the kinds in the google app engine datastore?
  • How can i know how many queries are fired in my database?
  • Export weka results on command line
  • How can jQuery DataTables be applied to AJAX rendered partial view in MVC4?
  • How to compute daily average for 15 years?
  • GPU Memory bandwidth theoretical vs practical
  • java: PropertyChangeSupport for Map or EnumMap?
  • Pointing EF to a database when the POCO files are in a seperate project
  • Facebook Profile.getCurrentProfile() is always returns null after the first login
  • Why does cpu load not change more than a few hundredths?
  • indexedDB doesn't reset version when you delete a database on Chrome — bug or user error?
  • Getting Javascript Errors From Another Window
  • JHipster Entity Generator crahing
  • Sql indexes vs full table scan
  • Sending Content-Type application/x-www-form-urlencoded WSO2 ESB
  • NUnit 3.0 TestCase const custom object arguments
  • Plotting line graph with factors in R
  • Graphics.CopyFromScreen [Web application] + The handle is invalid
  • Problem deserializing objects from cache on MyBatis 3/Java
  • Can you perform a UNION without a subquery in SQLAlchemy?
  • Database structure design with variable amounts of fields
  • FFmpeg Conversion Error
  • How do I fake an specific browser client when using Java's Net library?
  • How to get a value (ex: baseURL) in every Karate feature?
  • WinForms: two way TextBox problem
  • MySQL WHERE-condition in procedure ignored
  • Web-crawler for facebook in python
  • How to disable jQuery.jplayer autoplay?
  • How to include full .NET prerequisite for Wix Burn installer
  • trying to dynamically update Highchart column chart but series undefined
  • Qt: Run a script BEFORE make
  • Checking variable from a different class in C#
  • java string with new operator and a literal