问题
I am using wso2esb4.8.0 and wso2dss3.0.1.My issue is I wish to insert the data into 2 tables its working nicely but I wish to applay transaction for my tables both table exist in same DB.If my 2nd table going fail on any moment that time my 1 st table should be rollback for that my DSS data source configuration is
and my dataservice is like this and I enabled boxcar for transaction
<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>
I wish to insert my data for that my proxy is configured like this
<?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>
I am sending my data through CURL command
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
insertion is working fine but roll back is not working if I create error in 2nd table even though 1st table data inserting its not worrying about 2nd table.If I remove OUT_ONLY property its giving errors I followed this blogenter link description here
回答1:
Assuming you are using postgres, can you check whether you have set the "max_prepared_transactions" to a non zero value in "/etc/postgres/postgres.conf. Also you need OUT_ONLY property in this scenario as you are doing inserts and you are not expecting any responses. "You need to Set this property to ‘true’ on a message to indicate that no response message is expected for it once it is forwarded from the ESB."
来源:https://stackoverflow.com/questions/21112888/transaction-roll-back-not-working-in-wso2esb4-8-0