5

问题

如何通过 Spring 配置一个将allowCustomIsolationLevels设置为true的JtaTransactionManager对象,以便可以跨多个应用程序服务器使用 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 Transaction Manager 。但是,WebSphere 没有相同的 JNDI 位置。

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

<tx:jta-transaction-manager />

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

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

4

1 回答 1

2

事务管理器和 Websphere:

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

数据源和隔离级别

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

这里这里

于 2010-10-13T12:45:13.350 回答