2016-05-13 9 views
1

Box_caring機能を使用して3つのテーブルに挿入していますが、挿入は正しく行われていますが、テーブルに挿入する間に何らかのエラーが発生した場合、wso2 esbまたはwso2 dssでデータベーストランザクションロールバックを行う方法

私は以下の課題に対する解決策を探しています。主キー/外部キーの関係によって関連しており、関連テーブルのオブジェクトを更新/挿入する必要があります。イテレータメディエータ内で挿入/更新が行われます。いずれかの更新/挿入が失敗するとどうなりますか?挿入/更新されたオブジェクトはすべてロールバックされますか?

アイデアやリンク、コードスニペットを使用して機能させてください。

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

おかげ

答えて

0

ここでは、Distributed XAトランザクションを実装する必要があります。あなたはこれをガイドする記事[1]を参照してください。

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

+0

は、そのすべてについてのトランザクションとdbreport mediators.Butは、いくつかのエラーが発生した場合のメディエーターは、内部box_caringを探していますが、それは右のトランザクションをロールバックすることを意味することを使用する必要はありませんが、私の場合は起こっていない。 – Siddu

0

あなたは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機能を使用できます。この機能では、操作を介してセッションを維持する必要はありません。私はリンクを介して行っている

おかげ