如何在 wso2 esb 或 wso2 dss 中进行数据库事务回滚

How to do database transaction rollback in wso2 esb or wso2 dss(如何在 wso2 esb 或 wso2 dss 中进行数据库事务回滚)

本文介绍了如何在 wso2 esb 或 wso2 dss 中进行数据库事务回滚的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am inserting into three tables using Box_caring feature, insertion happening properly but if some error comes in between while inserting into tables its not roll backing the data.

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

I'm looking for a solution to the following challenge:Have a set of related tables. They are related by primary/foreign key relations and need to update/insert objects in the related tables. Insert/update happening inside iterator mediator. what happens when one of the updates/insert fails? Will all the inserted/updated objects rolled back?.

请提供任何想法或链接或代码片段以使其工作.

Please give any ideas or links or code snippet to make it work.

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

Note: Am using wso2 esb-4.8.1, wso2 dss-3.2.2 and MSSQL database

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

我们如何在 WSO2DSS 中回滚事务或WSO2ESB

提前致谢

推荐答案

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

When you are using box_carring feature, you have to maintain same session across all the operation calls. Otherwise, it will evaluates as separated calls and will not be atomic. Here is a sample synapse config that can be used to maintain the same session.

<?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 功能,但您不需要必须跨操作维护会话.

However, you can use request_box feature, where you do not have to maintain the session across operations.

谢谢

这篇关于如何在 wso2 esb 或 wso2 dss 中进行数据库事务回滚的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:如何在 wso2 esb 或 wso2 dss 中进行数据库事务回滚

基础教程推荐