【问题标题】:How to enable custom isolation levels for a JTA Transaction Manager in Spring如何在 Spring 中为 JTA 事务管理器启用自定义隔离级别
【发布时间】:2011-04-24 11:13:57
【问题描述】:

问题

如何配置 JtaTransactionManager 对象,通过 Spring 将 allowCustomIsolationLevels 设置为 true,以便 Spring 配置可以跨多个应用程序服务器使用?

背景:

我有一个应用程序当前用完了 JBossAS,我正试图让它在 WebSphere 中运行。我目前遇到的唯一问题是使用正确的设置注入正确的 JTA 事务管理器。

这是旧设置

<bean id="transactionManager"
    class="org.springframework.transaction.jta.JtaTransactionManager">
    <property name="transactionManagerName">
        <value>java:/TransactionManager</value>
    </property>
    <property name="allowCustomIsolationLevels" value="true" />
</bean>

这很有效,因为 JBossAS 在 JNDI 位置 java:/TransactionManager 定义了它的 JTA 事务管理器。但是,WebSphere 没有相同的 JNDI 位置。

Spring 2.5.x 提供了一种以通用方式获取 JTA 事务管理器的方法。

<tx:jta-transaction-manager />

这将获取 JtaTransactionManager 对象并将其定义为 id 为 transactionManager 的 bean。

我查看了Spring TX schema,但唯一可用的设置是设置特定的隔离级别,而不仅仅是允许使用自定义级别(如其他地方定义的那样)。 如何使用 tx:jta-transaction-manager 标签设置 allowCustomIsolationLevels 属性?

【问题讨论】:

  • 我想我可能已经找到了一个可能的解决方案,但仍然想看看 是否有办法。解决方法似乎是简单地从第一个代码块中删除属性“transactionManagerName”,Spring 将尝试通过 JNDI 自动检测事务管理器。

标签: java spring jta


【解决方案1】:

事务管理器和 Websphere:

Websphere 在提供事务管理器时不使用典型的 jndi 标准。 Spring 通过提供 org.springframework.transaction.jta.WebSphereUowTransactionManager 解决了这个问题,您可以使用它来查找 websphere 事务管理器。

数据源和隔离级别

您通常无法更改数据源的隔离级别,我知道在从 websphere 连接到 DB2 数据库时您无法更改它(它被设置为数据源配置中的参数)。 allowCustomIsolationLevels 标志可让您为不同的请求隔离级别选择不同的数据源..

herehere

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-09-11
    • 1970-01-01
    • 2015-07-21
    • 2019-03-17
    • 2020-06-07
    • 1970-01-01
    • 2014-02-22
    • 1970-01-01
    相关资源
    最近更新 更多