2013-04-10 60 views
1

我有2 sequences in my ESB,分别是“seqDeleteEntry”和“seqInsertEntry”。如何管理WSO2中的序列间的事务处理ESB

序列“seqDeleteEntry”将根据收到的输入从表中删除条目。
代码片段:

<sequence xmlns="http://ws.apache.org/ns/synapse"> 
    <property xmlns:ns="http://org.apache.synapse/xsd" name="propertyName" expression="//Id/text()" scope="default" type="STRING"/> 
    <transaction action="new"/> 
    <property name="SET_ROLLBACK_ONLY" value="true" scope="axis2"/>  
     <dbreport useTransaction="true"> 
      <connection> 
       <pool> 
        <password>$pwd</password> 
        <user>$uname</user> 
        <url>connectionURL</url> 
        <driver>$driver</driver> 
       </pool> 
      </connection> 
      <statement> 
       <sql> 
        <![CDATA[ delete from tbl_name where column_name = ?]]> 
       </sql> 
       <parameter expression="$ctx:propertyName" type="VARCHAR"/> 
      </statement> 
      </dbreport> 
      <sequence key="conf:/seqInsertEntry"/> 
    </sequence> 

序列 “seqInsertEntry” 将插入进入表。
代码片段:

<sequence xmlns="http://ws.apache.org/ns/synapse">  
      <dbreport useTransaction="true"> 
       <connection> 
        <pool> 
         <password>$pwd</password> 
         <user>$uname</user> 
         <url>connectionURL</url> 
         <driver>$driver</driver> 
        </pool> 
       </connection> 
       <statement> 
        <sql> 
         <![CDATA[ insert into tbl_name values('value1', 'value2')]]> 
        </sql> 
       </statement> 
       </dbreport> 
       <transaction action="commit"/> 
       <send/> 
     </sequence> 

我的问题是:
当有错误(比如Integrity Constraint Violation),而将第二序列(seqInsertEntry)项,我需要在这样的回滚事务应该恢复使用上一个序列(seqDeleteEntry)删除的记录。

我需要添加什么配置来实现上述示例中的事务管理?

注:
我试着设置以下属性,但它并不能帮助。

<transaction action="new"/> 
<property name="SET_ROLLBACK_ONLY" value="true" scope="axis2"/> 

而且我已经添加在DBReport以下属性(在这两个序列)和第二序列(seqInsertEntry)结束时提交的事务,仍然没有帮助。

useTransaction="true" 

有人请澄清我错过了什么配置或我需要添加上述序列。

在此先感谢。

回答

0
+1

嗨磨憨来实现,感谢您的链接...我看着上面给出的文档链接。但它不能帮助我。在上面的文档中,删除和插入(通过DBReport)的顺序相同,而在我的情况下,它们的顺序不同。此外,我尝试实施“faultSequence”,因为在链接也没有帮助。我认为交易不会按照我转发的顺序进行。有什么建议么?提前致谢。 – 2013-04-11 13:18:01

1

维杰,我的理解是交易不是跨越序列进行的,除了在错误序列中(以及错误同步发生时) Y)。事务似乎附加到序列和客户端。

您是如何执行故障顺序的?

如果我错了有关跨序列的交易,我将不胜感激知道如何能:-)