jta

JDBC事务和JTA事务的区别 --包含spring事务 声明式事务

ε祈祈猫儿з 提交于 2019-12-06 02:26:48
一、事务概述 事务表示一个由一系列的数据库操作组成的不可分割的逻辑单位,其中的操作要么全做要么全都不做。 与事务相关的操作主要有: BEGIN TRANSACTION; 开始一个事务,方法是:begin() COMMIT;       提交一个事务,方法是:commit() ROLLBACK;      回滚一个事务,方法是:rollback() PREPARE;      准备提交一个事务,方法是:prepare() 二、事务的特性(ACID) 1、原子性:同一个事务的操作要么全部成功执行,要么全部撤消 2、隔离性:事务的所有操作不会被其它事务干扰 3、一致性:在操作过程中不会破坏数据的完整性 4、时效性 :事务的结果必须持久保存于介质上 三、事务处理方式 在JDBC连接中,使用命令声明事务的开始、提交和取消。如前一章介绍的数据库处理方式,它通过java.sql.Connection接口实现,可以启用AutoCommit。这种方式使用简单,但性能较低。 利用JavaEE规范的JTA驱动程序。这种方式性能更好,是EJB和JMS的常用方式。 Java EE 的分布式事务服务包括5个层次:事务管理器、应用服务器、资源管理器、应用程序、通信资源管理器。 事务管理器:完成事务管理 应用服务器:为应用提供服务 资源管理器:连接相应的资源 应 用程 序:需要使用事务的应用 通信资源管理器

Two-phase commit (2PC) configuration with Atomikos

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-05 22:44:53
I am creating a sample application to test two-phase commit (2PC). I have taken the code bits used here from the Internet. I am using Spring, Hibernate and Atomikos with MySQL as the backend. I am using two databases and deliberately making the call to the second database fail to check whether the first database call gets rolled back. Sadly it doesn't seem to work. Can some one point me to some links with some sample code? Following is my configuration: The Hibernate session factories: <bean id="sessionFactory1" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> <property name

Wildfly 8.0.0.Final JTA transaction issues

可紊 提交于 2019-12-05 20:03:05
Since we use a lot of @ApplicationScoped beans with transaction but we do not want to use EJBs (ApplicationScoped bean does not work with stateless beans), we create our own transaction interceptor such as: @Resource UserTransaction tx; @Resource(mappedName="java:jboss/TransactionSynchronizationRegistry") TransactionSynchronizationRegistry tsr; @AroundInvoke public Object manageTransaction(InvocationContext context) throws Exception { Object result; if (Status.STATUS_NO_TRANSACTION == tsr.getTransactionStatus()) { tx.begin(); // System.out.println("Starting transaction"); result = context

How to use Container Managed Transaction (CMT) with JBoss AS 6, Hibernate 3.6, JPA, JTA and EJB3

折月煮酒 提交于 2019-12-05 17:59:25
I'm attempting to setup a web app using CMT. I've got it running standalone within Eclipse ok, and now I'm trying to get it working within Jboss AS 6, using Struts 1.0. I've chosen CMT because the doco I've read hints that it's the best and "least verbose to use". So seems like contempory/good-practice use of Hibernate 3.6. I can load objects from a MySQL database with the following code extracts, but persisted objects are not being flushed/synchronised/saved to the database: From within Struts 1.0 Action class: InitialContext ctx = new InitialContext(); EntityManagerFactory emf =

JTA的含义及应用简介

£可爱£侵袭症+ 提交于 2019-12-05 17:54:13
Java Transaction API(Java事务API) (JTA)Java Transaction API(Application Programming Interface) 什么是JTA Transaction?它有怎样的特点呢?JTA Transaction是指由J2EE Transaction manager去管理的事务。其最大的特点是调用UserTransaction接口的begin,commit和rollback方法来完成事务范围的界定,事务的提交和回滚。JTA Transaction可以实现同一事务对应不同的数据库,但是它仍然无法实现事务的嵌套。 分布式事务的规范由OMG的OTS所描述。 JTA是只是一组java接口用于描述,J2ee框架中事务管理器与应用程序,资源管理器,以及应用服务器之间的事务通讯。 它主要包括高层接口即面向应用程序的接口;XAResource接口即面向资源的接口;以及事务管理器的接口。值得注意的是JTA只提供了接口,没有具体的实现。 JTS是服务OTS的JTA的实现。简单的说JTS实现了JTA接口,并且符合OTS的规范。 资源管理器只要其提供给事务管理器的接口符合XA接口规范,就可以被事务管理器处理。 所以,JTA可以处理任何提供符合XA接口的资源。包括:数据库,JMS,商业对象等等 “Java 事务 API”(JTA)启用两阶段提交功能

Exception: Must start with Java agent to use InstrumentationLoadTimeWeaver. See Spring documentation

笑着哭i 提交于 2019-12-05 15:09:15
I'm getting exception when trying to execute test Please help . Thank you in advance I'm using : Java 7 , EclipseLink 2.5.0-SNAPSHOT, Spring 3.2.4 Test configuration file : <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer" p:location="classpath:jdbc.properties" /> <bean id="tttDataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource" p:driverClassName="${jdbc.driverClassName}" p:url="${jdbc.url}" p:username="${jdbc.username}" p:password="${jdbc.password}" /> <bean id="loadTimeWeaver" class="org.springframework

【分布式事务系列八】JTA深度历险-原理与实现

久未见 提交于 2019-12-05 07:58:13
#0 系列目录# 分布式事务 【分布式事务系列一】提出疑问和研究过程 【分布式事务系列二】Spring事务管理器PlatformTransactionManager 【分布式事务系列三】Spring的事务体系 【分布式事务系列四】分布式事务的概念 【分布式事务系列五】jotm的分布式案例 【分布式事务系列六】jotm分布式事务源码分析 【分布式事务系列七】Atomikos的分布式案例 【分布式事务系列八】JTA深度历险-原理与实现 在 J2EE 应用中,事务是一个不可或缺的组件模型, 它保证了用户操作的 ACID(即原子、一致、隔离、持久)属性 。对于只操作单一数据源的应用,可以通过本地资源接口实现事务管理;对于跨数据源(例如多个数据库,或者数据库与 JMS)的大型应用,则必须使用全局事务 JTA (Java Transaction API)。 JTA 为 J2EE 平台提供了分布式事务服务,它隔离了事务与底层的资源,实现了透明的事务管理方式 。 #1 利用 JTA 处理事务# ##1.1 什么是事务处理## 事务是计算机应用中不可或缺的组件模型, 它保证了用户操作的原子性 ( Atomicity )、一致性 ( Consistency )、隔离性 ( Isolation ) 和持久性 ( Durabilily ) 。关于事务最经典的示例莫过于信用卡转账:将用户 A 账户中的

乱想:由JTA蔓延到EJB

谁都会走 提交于 2019-12-05 07:58:01
最近一个项目服务端原来是用EJB + SSH 转到Play 1.x上,而且原框架是分布式部署,整个程序理论上可有N个节点,实际上最多有五个节点的调用。项目包括Delphi客户端,Java服务端,与Java数据中心。EJB就是运用在服务端与数据中心。在框架迁移的时候不免设计到远程调用的修改以及事务问题。 这里不讨论具体的实现,而是关于JTA与EJB的概念。说实在的,从踏上Java这条道,以前还没有遇到过EJB,可能这与所从事的行业都是互联网公司有关吧。对EJB知之甚少。不过感觉很神秘,很笨重的,很古老的样子。 这次迁移框架才不得不看看EJB相关的东西,不过一看就头痛。断断续续的看了一些东西,在改事务的时候,看到了JTA,其中产生了一个疑问,事务回滚时setRollBackOnly()与rollback()的应用场景的区别。可惜一直没有找到答案,只好回去看源码,在网上找JTA文章,不断刷搜索引擎,终于发现两篇好文章 JTA 深度历险 - 原理与实现 http://www.ibm.com/developerworks/cn/java/j-lo-jta/ EJB到底是什么,真的那么神秘吗?? http://blog.csdn.net/jojo52013145/article/details/5783677 前者解析了JTA的原理,后者揭开了EJB神秘的面纱。EJB用大白话来说,就是

What is a global transaction?

≯℡__Kan透↙ 提交于 2019-12-05 07:25:10
JSR 907 JTA 1.2 defines the "global transaction" term: The UserTransaction.begin method starts a global transaction and associates the transaction with the calling thread. What does that mean? Is it the outermost transaction or what? Basically the difference between a local transaction and a global transaction is resource bound. A global transaction will span multiple resources. A local transaction is limited to one resource/datasource. E.g. In a global transaction you will write to the DB and send a message over a queue. This is nicely explained here: http://integrationspot.blogspot.co.uk

Does jboss handle managed Entity Manager concurrency issues for me?

半腔热情 提交于 2019-12-04 17:04:19
It seems that the Entity Manager instance jboss manages and provides is a proxy to the actual implementation bound to a persistence context. This actual implementation gathers the isolation provided by JTA transactions (per transaction contexts). That makes me think I don't need to worry about concurrency issues when dealing with the proxy instance. Maybe I can even cache this proxy instance if I decide to bring it from JNDI lookups instead of container injection? Is that reasonable? The container is responsible for scanning for @PersistenceContext annotations and injection of EntityManagers .