我如何处理 WSO2ESB 中的错误序列 [英] How Can I handle Error sequence in WSO2ESB

查看:21
本文介绍了我如何处理 WSO2ESB 中的错误序列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用故障序列处理错误,但我希望使用删除操作对其进行自定义我的情况是,当我插入 2 个表时,如果在第二个表插入中发生错误,我需要删除第一行插入,我的配置也在下面

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>

而且顺序是这样的

<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>

故障序列是这样的

<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>

但是当 DSS 处于关闭模式时它无法正常工作让我知道当 DSS 处于运行模式时如何删除第一个表行

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

推荐答案

在 DSS 更新失败的场景中,它将向 ESB 发回 SOAP 错误.由于 ESB 这仍然只是另一个消息响应,它不会转到故障序列,除非您明确检查消息并执行必要的操作.所以你必须声明即将到来的消息是一个 SOAP_FAULT 所以你必须说它是一个 SOAP_FAULT 并强制它错误序列.这在 [1] 中有解释.

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] http:///maharachchi.blogspot.com/2012/09/now-you-can-send-soapfaults-to-fault.html

这篇关于我如何处理 WSO2ESB 中的错误序列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆