我正在使用wso2esb4.8.0和wso2dss3.0.1。我的问题是我希望将数据插入到2个表中,它的工作正常但是我希望为我的表applay事务,这两个表存在于同一个DB中。如果我的第二个表继续在我的第一个表应该回滚的任何时刻失败 为此,我的DSS数据源配置为
我的数据服务是这样的,我启用了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>
我想插入我的数据,因为我的代理配置如下
<?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
答案 0 :(得分:0)
假设你正在使用postgres,你可以检查一下你是否在“/etc/postgres/postgres.conf”中将“max_prepared_transactions”设置为非零值。此外,在这种情况下你需要OUT_ONLY属性,因为你正在进行插入和你不期待任何回复。“你需要在一条消息上将此属性设置为'true',以指示从ESB转发后不会有响应消息。”