Mule 3.3.0 Jdbc事务意外提交 [英] Mule 3.3.0 Jdbc Transaction Undesired Commit

查看:111
本文介绍了Mule 3.3.0 Jdbc事务意外提交的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试设置jdbc事务的虚拟示例以测试提交和回滚.这里我有:

I'm trying to setup a dummy example of jdbc transaction to test commit and rollback. Here I've got :

  • 开始流程的http入口点
  • 在db上插入会引发异常的组件
  • 数据库的更新.

我希望在组件异常插入之后会回滚,但事实并非如此. 调试m子源我已经看到在类BeginAndResolveTransactionInterceptor中,insert语句以commit终止,因为resolveStartedTransaction属性设置为true. 这就是为什么我认为在default-exception-strategy中无法回滚的原因... 我不知道我在配置中做错了还是行为错误.

I expect that after component exception insert were rollback but it doesn't. Debugging mule source I've seen that in class BeginAndResolveTransactionInterceptor the insert statement terminate with a commit because resolveStartedTransaction property is set to true. This is why in default-exception-strategy rollback doesn't work I suppose... I don't know if I'm doing something wrong in configuration or if is a wrong behavior.

<spring:beans>
        <spring:bean id="sqlServerDataSource" name="sqlServerDataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
            <spring:property name="password" value="${db.connection.password}"/>
            <spring:property name="url" value="${db.connection.url}"/>
            <spring:property name="username" value="${db.connection.username}"/>
            <spring:property name="driverClassName" value="${db.connection.driver_class}"/>
        </spring:bean>
        <spring:bean id="sqlServerSqlStatementStrategyFactory" name="sqlServerSqlStatementStrategyFactory" class="it.clesius.ebs.common.db.SqlServerSqlStatementStrategyFactory"/>
        <spring:bean id="DBRecord1" class="org.apache.commons.dbutils.handlers.BeanListHandler">
            <spring:constructor-arg value="it.clesius.esb.db.beans.DBRecord1"/>
        </spring:bean>
    </spring:beans>
<jdbc:connector name="JDBC_Connector" dataSource-ref="sqlServerDataSource" resultSetHandler-ref="DBRecord1" validateConnections="true" transactionPerMessage="false" queryTimeout="-1" pollingFrequency="0" doc:name="JDBC_Connector">
        <!-- jdbc:sqlStatementStrategyFactory ref="sqlServerSqlStatementStrategyFactory"/>
        <spring:property name="retryPolicyTemplate">
            <spring:bean class="org.mule.retry.policies.SimpleRetryPolicyTemplate">
                <spring:property name="count" value="10"/>
                <spring:property name="frequency" value="60000"/>
            </spring:bean>
        </spring:property -->

    </jdbc:connector>
    <flow name="DBTestFlow" doc:name="DBTestFlow">
        <http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8083" path="db" doc:name="HTTP"/>
        <message-properties-transformer doc:name="Add db properties">
            <add-message-property key="db.connection.driver_class" value="${db.connection.driver_class}"/>
            <add-message-property key="db.connection.password" value="${db.connection.password}"/>
            <add-message-property key="db.connection.url" value="${db.connection.url}"/>
            <add-message-property key="db.connection.username" value="${db.connection.username}"/>
        </message-properties-transformer>
        <jdbc:outbound-endpoint exchange-pattern="request-response" queryKey="InsertTest" responseTimeout="10000" mimeType="text/plain" queryTimeout="-1" connector-ref="JDBC_Connector" doc:name="Database (JDBC)">
            <jdbc:transaction action="ALWAYS_BEGIN" />
            <!-- property key="receiveMessageInTransaction" value="true" /-->
            <jdbc:query key="InsertTest" value="INSERT INTO [ClesiusICEF_DEV].[dbo].[AAATEST_CANCELLLAMIPUREQUANDOVUOI] ([F1],[F2],[F3]) VALUES ('1','2','3')"/>
        </jdbc:outbound-endpoint>
        <component class="it.clesius.esb.ExceptionTest" doc:name="Break Flow with an Exception to Test Transaction Rollback"/>
        <jdbc:outbound-endpoint exchange-pattern="request-response" queryKey="UpdateTest" responseTimeout="10000" mimeType="text/plain" queryTimeout="-1" connector-ref="JDBC_Connector" doc:name="Database (JDBC)">
            <jdbc:transaction action="ALWAYS_JOIN" />
            <jdbc:query key="UpdateTest" value="UPDATE [ClesiusICEF_DEV].[dbo].[AAATEST_CANCELLLAMIPUREQUANDOVUOI] SET [F1]='Aggiornato'"/>
        </jdbc:outbound-endpoint>
        <default-exception-strategy>
            <rollback-transaction exception-pattern="*"/>
            <logger level="INFO" message="!!!!!!!!!!TRANSAZIONE ANNULLATA!!!!!!!!!!!!!!!!!!!!!!!!!!!111" doc:name="Logger"/>
        </default-exception-strategy>
    </flow>

推荐答案

好,我找到了一种解决方法.如果事务是由vm而不是jdbc启动的,则可以正常工作. jdbc/transaction中可能存在一个错误,该错误总是在首次进行事务处理时提交 端点是jdbc.

ok I've found a workaround. If transaction is started by vm instead of jdbc it works fine. Probably there is a bug in jdbc/transaction that make commit always when first transactional endpoint is jdbc.

这篇关于Mule 3.3.0 Jdbc事务意外提交的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆