0

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 isenter image description here

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

Community
  • 1
  • 1
Faisal
  • 1,469
  • 2
  • 13
  • 25

1 Answers1

0

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."

poohdedoo
  • 1,258
  • 1
  • 18
  • 42
  • i have done but no result #max_prepared_transactions = 5 # zero disables the feature .postgres restarted also manullay created arror in 2nd table so my 1st table inserting nd 2nd one failing no transaction roll back occuring... – Faisal Jan 15 '14 at 05:27
  • i have created error in 2nd table like this Default Namespace: http://ws.wso2.org/dataservice Current Request Name: insertinto_mcompany_OP Current Params: {comapnyname=, clientid=11, modifiedbyid=-1, companycode=, createdbyid=-1} Nested Exception:- org.postgresql.util.PSQLException: ERROR: insert or update on table "mcompany" violates foreign key constraint "FK_mclient_clientid" Detail: Key (clientid)=(11) is not present in table "mclient" first table inserting well but 2nd table went wrong i wish to rollback 1st table also but no use of this way.. – Faisal Jan 15 '14 at 05:37
  • Can you try the above insertions using DSS try-it feature first? and see if it works? You need to call begin_boxcar -> inserts -> end_boxcar – poohdedoo Jan 15 '14 at 05:47
  • 1
    ya its working in DSS try-it..fine wow awesome but not in wso2esb – Faisal Jan 15 '14 at 06:22
  • but while i am calling for failure scenario its giving error like this ******[2014-01-15 11:56:36,227] ERROR {org.apache.axis2.engine.AxisEngine} - The endpoint reference (EPR) for the Operation not found is /services/Transaction/ and the WSA Action = null. If this EPR was previously reachable, please contact the server administrator. org.apache.axis2.AxisFault: The endpoint reference (EPR) for the Operation not found is /services/Transaction/ and the WSA Action = null. If this EPR was previously reachable, please contact the server administrato******** – Faisal Jan 15 '14 at 06:28
  • its coming every time success and failure scenario above error following every time what is the issue behind this.. – Faisal Jan 15 '14 at 06:35
  • Hmm looks like the soap action is not properly getting set can you try changing the call out Endpoint URL by adding the action as well (just a hunch) ie http://192.168.1.201:9764/services/Transaction/opperationName (however, ideally by setting the action in call out should set the Action) – poohdedoo Jan 15 '14 at 07:14
  • for begin box_carrying and end_car its showing above error in wso2dds what is the issue behind this i correctly aaded the header action also and for remaining its notshowing above error – Faisal Jan 15 '14 at 07:25
  • i added the operation for endpoint http://192.168.1.201:9764/services/Transaction/begin_boxcar and http://192.168.1.201:9764/services/Transaction/end_boxcar..but no use no errors and not working transaction also 1st table inserting even 2nd failur – Faisal Jan 15 '14 at 07:33