问题描述
是否可以在 Java 中对文件系统进行 XA 事务访问?我想在事务边界内操作文件,我的事务必须通过 JTA 参与分布式事务(所以我猜文件系统需要作为 XAResource 访问).我不需要对细粒度读/写文件访问的支持;将每个文件视为记录足以满足我的需求.
Is it possible to make XA-transactional access to the file system in Java?I want to manipulate files within the boundaries of a transaction and my transaction must participate in a distributed transaction via JTA (so I guess the file system needs to be accesses as a XAResource). I don't need support for fine-grained read/write file access; treating each file as a record is good enough for my needs.
有没有人知道一个已经这样做的开源项目?我不想实施这个烂摊子只是为了发现它已经完成了......
Does anybody know an open-source project that already does this? I don't feel like implementing this mess just to find out that it's already been done...
我听到一些传言说 JBoss Transcations 将添加对此的支持(例如参见 这个讨论) 但找不到关于此的官方声明.
I heard some rumors that JBoss Transcations will add support for this (see for example this discussion) but couldn't find an official statement about this.
顺便说一下,如果您需要事务文件访问但不需要事务参与两阶段提交,我建议您查看 Apache 公共事务
By the way, if you need transactional file access but don't require the transaction to participate in a 2-phase commit I recommend you have a look at Apache Commons Transaction
可以在此处中找到有关所涉及的复杂性的精彩文章.
A nice article about the complexities involved can be found in here.
推荐答案
最近我解决了完全相同的问题.最后,我将 Bitronix 与 XADisk 一起使用.
Recently I solved exactly the same problem. Finally I used Bitronix with XADisk.
您可以在我的博客文章中找到更多详细信息:JTA 事务管理器——Atomikos 还是 Bitronix?
You can find more details in my blog post: JTA transaction manager – Atomikos or Bitronix?
这篇关于是否有针对 Java 中 XA 事务文件访问的开源解决方案?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!