管理交易的最佳方式 [英] Best way to manage transactions

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

问题描述

我有基于JBoss和Hibernate的系统。
我需要处理两个长操作。操作可能比事务超时更长。
它在两个不同的交易中持续存在许多实体。
如果出现问题,在此操作期间,我应该回滚所有交易的更改。

I've the JBoss and Hibernate based system. And I need to process two long operations. Operations can be probably longer than transaction's timeout. It operations are persists many-many entities, in two different transactions. And if something goes wrong, during this operations, I should rollback all changes of the transactions.

解决问题的最佳方法是什么?

What's the best way to resolve it?

我认为,最好的方法是将所有操作合并到一个事务中,但它需要设置LOng事务超时,并且它对我们的系统是不可接受的。

I think, the best way is merge all operations to one transaction, but it requires to set LOng transaction timeout, and it unacceptable for our system.

在这种情况下,许多交易的管理更好。我该怎么做?

Is the managing of many transactions better in this situation. And how can I do it?

推荐答案

您可以使用JTA服务器(事务协调器)以多个步骤XA交易? 这篇文章有一些粉丝,出来一些开源的,可能适合你。

Can you use a JTA server (transaction coordinator) to do the transaction in multiple steps with XA transactions? This posting has a bit of fan-out to a couple of open-source ones that might work for you.

XA事务处理允许您执行一系列较小的操作,并在一次命中时提交或回滚它们。试着搜索'hibernate xa transactions'。大多数现代RDBMS平台(MySQL 5.x,PostgreSQL,SQL Server,Oracle,DB2,Sybase等)都支持XA事务。

XA transactions allow you to do a bunch of smaller operations and commit or roll back them in one hit. Try googling for 'hibernate xa transactions'. Most modern RDBMS platforms (MySQL 5.x, PostgreSQL, SQL Server, Oracle, DB2, Sybase etc.) support XA transactions.

这篇关于管理交易的最佳方式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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