【问题标题】:How to do database transaction rollback in wso2 esb or wso2 dss如何在 wso2 esb 或 wso2 dss 中进行数据库事务回滚
【发布时间】:2018-01-19 22:06:55
【问题描述】:

我正在使用 Box_caring 功能插入三个表,插入正常进行,但如果在插入表时出现一些错误,它不会回滚数据。

我正在寻找以下挑战的解决方案:拥有一组相关表格。它们通过主/外键关系相关,需要在相关表中更新/插入对象。插入/更新发生在迭代器调解器内。当其中一项更新/插入失败时会发生什么?所有插入/更新的对象都会回滚吗?

请提供任何想法或链接或代码 sn-p 以使其工作。

注意:我使用的是 wso2 esb-4.8.1、wso2 dss-3.2.2 和 MSSQL 数据库

通过以下链接: http://charithaka.blogspot.in/2014/02/common-mistakes-to-avoid-in-wso2-esb-1.html

How we can ROLLBACK the Transaction in WSO2DSS or WSO2ESB

提前致谢

【问题讨论】:

    标签: sql-server wso2 esb wso2dss


    【解决方案1】:

    在这里您必须实现分布式 XA 事务。您能否参考文章 [1] 来指导您完成此操作。

    [1]https://docs.wso2.com/display/ESB490/Sample+657%3A+Distributed+Transaction+Management

    【讨论】:

    • 我已经浏览了这个链接,它都是关于事务和 dbreport 中介的。但是不想使用那个中介,我在 box_caring 里面寻找如果发生一些错误意味着它会正确回滚事务但是在我的情况下没有发生。
    【解决方案2】:

    当您使用 box_carring 功能时,您必须在所有操作调用中保持相同的会话。否则,它将评估为单独的调用并且不会是原子的。这是一个可用于维护相同会话的示例突触配置。

    <?xml version="1.0" encoding="UTF-8"?>
    <proxy xmlns="http://ws.apache.org/ns/synapse"
           name="ESBService"
           transports="https http"
           startOnLoad="true"
           trace="disable">
       <description/>
       <target>
          <inSequence>
             <transaction action="new"/>
             <property name="id" expression="json-eval($.id)"/>
             <property name="userName" expression="json-eval($.userName)"/>
             <property name="firstName" expression="json-eval($.firstName)"/>
             <property name="lastName" expression="json-eval($.lastName)"/>
             <property name="address" expression="json-eval($.address)"/>
             <enrich>
                <source type="body" clone="true"/>
                <target type="property" property="FirstBody"/>
             </enrich>
             <property name="messageType" value="application/xml" scope="axis2"/>
             <header name="Action" value="urn:begin_boxcar"/>
             <payloadFactory media-type="xml">
                <format>
                   <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
                                     xmlns:dat="http://ws.wso2.org/dataservice">
                      <soapenv:Header/>
                      <soapenv:Body>
                         <dat:begin_boxcar/>
                      </soapenv:Body>
                   </soapenv:Envelope>
                </format>
                <args/>
             </payloadFactory>
             <call>
                <endpoint>
                   <address uri="http://localhost:9764/services/testService.SOAP11Endpoint/"/>
                </endpoint>
             </call>
             <property name="setCookieHeader" expression="$trp:Set-Cookie"/>
             <property name="Cookie"
                       expression="get-property('setCookieHeader')"
                       scope="transport"/>
             <property name="OUT_ONLY" value="true"/>
             <payloadFactory media-type="xml">
                <format>
                   <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
                                     xmlns:dat="http://ws.wso2.org/dataservice">
                      <soapenv:Header/>
                      <soapenv:Body>
                         <p:insert_employee xmlns:p="http://ws.wso2.org/dataservice">
                            <xs:UserId xmlns:xs="http://ws.wso2.org/dataservice">$1</xs:UserId>
                            <xs:userName xmlns:xs="http://ws.wso2.org/dataservice">$2</xs:userName>
                            <xs:firstName xmlns:xs="http://ws.wso2.org/dataservice">$3</xs:firstName>
                            <xs:lastName xmlns:xs="http://ws.wso2.org/dataservice">$4</xs:lastName>
                         </p:insert_employee>
                      </soapenv:Body>
                   </soapenv:Envelope>
                </format>
                <args>
                   <arg evaluator="xml" expression="get-property('id')"/>
                   <arg evaluator="xml" expression="get-property('userName')"/>
                   <arg evaluator="xml" expression="get-property('firstName')"/>
                   <arg evaluator="xml" expression="get-property('lastName')"/>
                </args>
             </payloadFactory>
             <property name="Content-Encoding" scope="transport" action="remove"/>
             <property name="Cookie"
                       expression="get-property('setCookieHeader')"
                       scope="transport"/>
             <call>
                <endpoint>
                   <address uri="http://localhost:9764/services/testService.SOAP11Endpoint/"/>
                </endpoint>
             </call>
             <payloadFactory media-type="xml">
                <format>
                   <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
                                     xmlns:dat="http://ws.wso2.org/dataservice">
                      <soapenv:Header/>
                      <soapenv:Body>
                         <dat:end_boxcar/>
                      </soapenv:Body>
                   </soapenv:Envelope>
                </format>
                <args/>
             </payloadFactory>
             <property name="Content-Encoding" scope="transport" action="remove"/>
             <property name="Cookie"
                       expression="get-property('setCookieHeader')"
                       scope="transport"/>
             <call>
                <endpoint>
                   <address uri="http://localhost:9764/services/testService.SOAP11Endpoint/"/>
                </endpoint>
             </call>
             <respond/>
          </inSequence>
          <faultSequence>
             <log>
                <property name="END" value="****ROLLBACK****"/>
             </log>
             <transaction action="rollback"/>
             <respond/>
          </faultSequence>
       </target>
    </proxy>
    

    但是,您可以使用request_box 功能,您不必跨操作维护会话。

    谢谢

    【讨论】:

      猜你喜欢
      • 2014-01-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多