没有交易的JTA数据源 [英] JTA Datasources without transactions

查看:160
本文介绍了没有交易的JTA数据源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

(假设手动征募和撤消资源.)

(Assuming manual enlistment and delistment of resources.)

我有许多XA启用的资源/数据源,我计划对其执行事务更新.此外,可以单独更新某些启用XA的数据源(不需要任何其他资源).

I have a number of XA enabled resources/datasource for which I plan to perform transactional updates. Additionally, some of the XA-enabled datasources can be updated in isolation (without requiring any other resource).

假设我已经使用数据源提交了许多事务,那么我可以忽略TransactionManager进行数据源的单方面更新吗.

Assuming I have already committed a number of transactions with a datasource enlisted, can I then ignore the TransactionManager for unilateral updates to the datasource.

我是否只是不启动全局事务并直接对资源本身进行提交?假设这是正确的方法,那么我可以随后在没有副作用的情况下将资源注册到事务中吗?

Do I simply not start a global transaction and commit directly on the resource itself? Assuming this is the correct approach, can I then subsequently enlist the resource in a transaction without side-effect?

谢谢

克里斯

推荐答案

XA资源 support XA.不是需要.因此,完全有可能在支持XA的资源上启动非XA事务,然后在本地提交它.

XA-resources support XA. Not require. Therefore it is totally possible to start a non-XA transaction over an XA-supporting resource, and commit it locally.

第二个问题不是很清楚.将本地事务下的资源添加到XA事务中?不确定这是受支持的用例.或问题是在提交本地事务后,我可以将资源添加到XA事务中吗?".是的,可以.

The second question is not quite clear. Add a resource under local transaction into XA transaction? Not sure it is a supported use-case. Or the question is "can I add the resource to an XA transaction after I have committed the local one?". Yes, you can.

让我们以数据库连接为例.通过连接启动本地事务时,事务ID仅存在于数据库中.提交后,该ID将消失,并且连接将恢复为原始状态,即不在任何事务中.可以将连接添加到任何XA事务中.

Let's take an example of database connection for instance. When a local transaction is started over the connection, the transaction ID exists within the database only. When committed, that ID is gone, and connection is back to the original state, i.e. not within any transaction. Connection can be added to any XA transaction.

现在,当您开始XA事务时,多个连接(例如,来自集群中不同JVM的连接)可以共享相同的事务ID,从数据库的角度来看,它们位于同一事务中.如果您在本地事务中有另一个连接,该连接具有它自己的数据库事务ID,那么如何将该连接(以及更重要的是在其中进行的更改)添加到具有不同ID的现有XA中?这将是一团糟,我相信不支持.

Now, when you start an XA transaction, multiple connections (e.g. from different JVMs in a cluster) can share the same transaction ID, and from DB point of view they are within the same transaction. If you have another connection in a local transaction, which has it's own transaction ID for the database, how would you add that connection (and, more importantly, the changes made within it) into the existing XA with a different ID? It would be a messy business, and I believe is not supported.

这篇关于没有交易的JTA数据源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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