如何在 Spring 中为 JTA 事务管理器启用自定义隔离级别

发布于 2024-09-27 07:32:38 字数 1237 浏览 2 评论 0原文

问题

如何通过 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 事务管理器以来,它就起作用了。但是,WebSphere 没有相同的 JNDI 位置。

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

<tx:jta-transaction-manager />

这将获取JtaTransactionManager对象并将其定义为具有idtransactionManager的bean。

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

Question

How do I configure a JtaTransactionManager object with allowCustomIsolationLevels set to true via Spring such that the Spring configuration can be used across multiple application servers?

Background:

I have an application that is currently running out of JBossAS and I'm trying to get it to run in WebSphere. The only issue I'm currently having is getting the correct JTA Transaction Manager injected with the proper settings.

Here's the old setting

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

This worked since JBossAS has it's JTA Transaction Manager defined at JNDI location java:/TransactionManager. However, WebSphere does not have the same JNDI location.

Spring 2.5.x provides a way to get the JTA Transaction Manager in a generalized way.

<tx:jta-transaction-manager />

This gets the JtaTransactionManager object and defines it as a bean with the id transactionManager.

I looked in the Spring TX schema, but the only setting available is to set a specific isolation level, but not just to allow custom levels to be used (as defined elsewhere). How do I set the allowCustomIsolationLevels property using the tx:jta-transaction-manager tag?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

苏辞 2024-10-04 07:32:38

事务管理器和 Websphere:

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

数据源和隔离级别

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

请参阅 此处此处

Transaction Managers and Websphere:

Websphere does not use the typical jndi standard when supplying the transaction manager. Spring has worked around this by providing the org.springframework.transaction.jta.WebSphereUowTransactionManager that you can use to lookup the websphere transaction manager.

Datasource and Isolation Levels

You typically cannot change the isolation level of a datasource and I know you cannot change it when connecting from websphere to DB2 database (it's set as a parameter on the datasource configuration). The allowCustomIsolationLevels flag lets you select different data sources for different requested isolation levels..

See here and here

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文