【问题标题】:Transaction roll back not working in wso2esb4.8.0事务回滚在 wso2esb4.8.0 中不起作用
【发布时间】:2014-03-07 14:37:26
【问题描述】:

我正在使用 wso2esb4.8.0 和 wso2dss3.0.1。我的问题是我希望将数据插入 2 个工作良好的表中,但我希望为我的表应用事务,这两个表都存在于同一个数据库中。如果我的第二个表去在我的第一张桌子应该回滚的任何时候失败 因为我的 DSS 数据源配置是

我的数据服务是这样的,我启用了 boxcar 进行交易

<data disableStreaming="true" enableBoxcarring="true" name="Transaction" serviceNamespace="http://ws.wso2.org/dataservice">
   <config id="default">
      <property name="carbon_datasource_name">USCProduction</property>
   </config>
   <query id="insertinto_mclient" useConfig="default">
      <sql>insert into mclient(clientcode,clientname,createdbyid,modifiedbyid) values(?,?,?,?)</sql>
      <param name="clientcode" ordinal="1" sqlType="STRING"/>
      <param name="clientname" ordinal="2" sqlType="STRING"/>
      <param name="createdbyid" ordinal="3" sqlType="BIGINT"/>
      <param name="modifiedbyid" ordinal="4" sqlType="BIGINT"/>
   </query>
   <query id="insertinto_mcompany" useConfig="default">
      <sql>insert into mcompany(companycode,companyname,createdbyid,modifiedbyid,clientid) values(?,?,?,?,?)</sql>
      <param name="companycode" ordinal="1" sqlType="STRING"/>
      <param name="comapnyname" ordinal="2" sqlType="STRING"/>
      <param name="createdbyid" ordinal="3" sqlType="BIGINT"/>
      <param name="modifiedbyid" ordinal="4" sqlType="BIGINT"/>
      <param name="clientid" ordinal="5" sqlType="BIGINT"/>
   </query>
   <operation disableStreaming="true" name="insertinto_mclient_OP" returnRequestStatus="true">
      <call-query href="insertinto_mclient">
         <with-param name="clientcode" query-param="clientcode"/>
         <with-param name="clientname" query-param="clientname"/>
         <with-param name="createdbyid" query-param="createdbyid"/>
         <with-param name="modifiedbyid" query-param="modifiedbyid"/>
      </call-query>
   </operation>
   <operation disableStreaming="true" name="insertinto_mcompany_OP" returnRequestStatus="true">
      <call-query href="insertinto_mcompany">
         <with-param name="companycode" query-param="companycode"/>
         <with-param name="comapnyname" query-param="comapnyname"/>
         <with-param name="createdbyid" query-param="createdbyid"/>
         <with-param name="modifiedbyid" query-param="modifiedbyid"/>
         <with-param name="clientid" query-param="clientid"/>
      </call-query>
   </operation>
</data>

我希望插入我的数据,因为我的代理配置如下

<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
       name="TransactionProxy"
       transports="https,http"
       statistics="disable"
       trace="disable"
       startOnLoad="true">
   <target>
      <inSequence>
         <log level="full">
            <property name="M1" value="*************HITTING Transaction PROXY*************"/>
         </log>
         <property name="OUT_ONLY" value="true"/>
         <property name="companycode" expression="//companycode/text()"/>
         <property name="companyname" expression="//companyname/text()"/>
         <property name="clientcode" expression="//clientcode/text()"/>
         <property name="clientname" expression="//clientname/text()"/>
         <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/>
               </soapenv:Envelope>
            </format>
            <args/>
         </payloadFactory>
         <log level="full"/>
         <callout serviceURL="http://192.168.1.201:9764/services/Transaction/"
                  action="urn:begin_boxcar">
            <source type="envelope"/>
            <target xpath="s11:Body/child::*[fn:position()=1] | s12:Body/child::*[fn:position()=1]"/>
         </callout>
         <payloadFactory media-type="xml">
            <format>
               <p:insertinto_mclient_OP xmlns:p="http://ws.wso2.org/dataservice">
                  <xs:clientcode xmlns:xs="http://ws.wso2.org/dataservice">$1</xs:clientcode>
                  <xs:clientname xmlns:xs="http://ws.wso2.org/dataservice">$2</xs:clientname>
                  <xs:createdbyid xmlns:xs="http://ws.wso2.org/dataservice">-1</xs:createdbyid>
                  <xs:modifiedbyid xmlns:xs="http://ws.wso2.org/dataservice">-1</xs:modifiedbyid>
               </p:insertinto_mclient_OP>
            </format>
            <args>
               <arg evaluator="xml" expression="get-property('clientcode')"/>
               <arg evaluator="xml" expression="get-property('clientname')"/>
            </args>
         </payloadFactory>
         <callout serviceURL="http://192.168.1.201:9764/services/Transaction/"
                  action="urn:insertinto_mclient_OP">
            <source xmlns:s12="http://www.w3.org/2003/05/soap-envelope"
                    xmlns:s11="http://schemas.xmlsoap.org/soap/envelope/"
                    xpath="s11:Body/child::*[fn:position()=1] | s12:Body/child::*[fn:position()=1]"/>
            <target xmlns:s12="http://www.w3.org/2003/05/soap-envelope"
                    xmlns:s11="http://schemas.xmlsoap.org/soap/envelope/"
                    xpath="s11:Body/child::*[fn:position()=1] | s12:Body/child::*[fn:position()=1]"/>
         </callout>
         <payloadFactory media-type="xml">
            <format>
               <p:insertinto_mcompany_OP xmlns:p="http://ws.wso2.org/dataservice">
                  <xs:companycode xmlns:xs="http://ws.wso2.org/dataservice">$1</xs:companycode>
                  <xs:comapnyname xmlns:xs="http://ws.wso2.org/dataservice">$2</xs:comapnyname>
                  <xs:createdbyid xmlns:xs="http://ws.wso2.org/dataservice">-1</xs:createdbyid>
                  <xs:modifiedbyid xmlns:xs="http://ws.wso2.org/dataservice">-1</xs:modifiedbyid>
                  <xs:clientid xmlns:xs="http://ws.wso2.org/dataservice">11</xs:clientid>
               </p:insertinto_mcompany_OP>
            </format>
            <args>
               <arg evaluator="xml" expression="get-property('companycode')"/>
               <arg evaluator="xml" expression="get-property('companyname')"/>
            </args>
         </payloadFactory>
         <log level="full">
            <property name="message2" value="**************hitting2nd dss*****"/>
         </log>
         <callout serviceURL="http://192.168.1.201:9764/services/Transaction/"
                  action="urn:insertinto_mcompany_OP">
            <source xmlns:s12="http://www.w3.org/2003/05/soap-envelope"
                    xmlns:s11="http://schemas.xmlsoap.org/soap/envelope/"
                    xpath="s11:Body/child::*[fn:position()=1] | s12:Body/child::*[fn:position()=1]"/>
            <target xmlns:s12="http://www.w3.org/2003/05/soap-envelope"
                    xmlns:s11="http://schemas.xmlsoap.org/soap/envelope/"
                    xpath="s11:Body/child::*[fn:position()=1] | s12:Body/child::*[fn:position()=1]"/>
         </callout>
         <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/>
               </soapenv:Envelope>
            </format>
            <args/>
         </payloadFactory>
         <callout serviceURL="http://192.168.1.201:9764/services/Transaction/"
                  action="urn:end_boxcar">
            <source type="envelope"/>
            <target xpath="s11:Body/child::*[fn:position()=1] | s12:Body/child::*[fn:position()=1]"/>
         </callout>
      </inSequence>
      <outSequence>
         <send/>
      </outSequence>
   </target>
   <description/>
</proxy>

我通过 CURL 命令发送我的数据

curl -v -H "Accept: application/xml" -H "Content-Type:application/xml"  -d '<a><clientcode>ff</clientcode><clientname>ffff</clientname><companycode>dd</companycode><companyname>mm</companyname></a>' http://youtility2-desktop:8290/services/TransactionProxy

插入工作正常,但如果我在第二个表中创建错误,即使第一个表数据插入它不担心第二个表,回滚也不起作用。如果我删除 OUT_ONLY 属性它给出的错误我遵循了这个博客enter link description here

【问题讨论】:

    标签: transactions wso2 wso2esb wso2dss


    【解决方案1】:

    假设您使用的是 postgres,您能否检查您是否已在“/etc/postgres/postgres.conf”中将“max_prepared_transactions”设置为非零值。此外,在这种情况下,您需要 OUT_ONLY 属性,因为您正在执行插入和您不希望得到任何响应。“您需要在消息上将此属性设置为 'true',以表明一旦从 ESB 转发该消息,就不会对其预期任何响应消息。”

    【讨论】:

    • 我已经完成但没有结果 #max_prepared_transactions = 5 # 零禁用该功能 .postgres 重新启动也手动在第二个表中创建了错误所以我的第一个表插入第二个失败没有事务回滚发生...
    • 我在第二个表中创建了这样的错误 默认命名空间:ws.wso2.org/dataservice 当前请求名称:insertinto_mcompany_OP 当前参数:{comapnyname=, clientid=11, modifiedbyid=-1, companycode=, createdbyid=- 1}嵌套异常:-org.postgresql.util.PSQLException:错误:插入或更新表“mcompany”违反外键约束“FK_mclient_clientid”详细信息:键(clientid)=(11)首先在表“mclient”中不存在表插入很好但第二张表出错了我也希望回滚第一张表但不使用这种方式..
    • 您可以先使用 DSS try-it 功能尝试上述插入吗?看看它是否有效?你需要调用 begin_boxcar -> inserts -> end_boxcar
    • 是的,它在 DSS 中工作,试试吧.. 哇很棒,但在 wso2esb 中没有
    • 但是当我要求失败场景时,它会给出这样的错误 ******[2014-01-15 11:56:36,227] ERROR {org.apache.axis2.engine.AxisEngine } - 未找到操作的端点引用 (EPR) 是 /services/Transaction/ 并且 WSA 操作 = null。如果此 EPR 以前可以访问,请联系服务器管理员。 org.apache.axis2.AxisFault:找不到操作的端点引用 (EPR) 是 /services/Transaction/ 并且 WSA Action = null。如果此 EPR 以前可以访问,请联系服务器管理员********
    猜你喜欢
    • 2014-02-03
    • 2011-01-17
    • 1970-01-01
    • 2017-09-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多