jta

spring boot + jta + druid整合demo

非 Y 不嫁゛ 提交于 2019-12-04 07:48:56
地址: https://gitee.com/liuchangng/springboot-mybatis-jta 项目使用到的技术如下: spring boot mybatis jta (分布式事务) druid (多数据源) 地址: https://gitee.com/liuchangng/springboot-mybatisplus-jta 项目使用到的技术如下: spring boot mybatis-plus (增强的mybatis) jta (分布式事务) druid (多数据源) 视频地址: https://pan.baidu.com/s/1kVOh18F ps: sql文件在entity目录下 来源: oschina 链接: https://my.oschina.net/u/2829982/blog/1544878

JTA 深度历险

不羁岁月 提交于 2019-12-04 07:48:37
利用 JTA 处理事务 什么是事务处理 事务是计算机应用中不可或缺的组件模型,它保证了用户操作的原子性 ( Atomicity )、一致性 ( Consistency )、隔离性 ( Isolation ) 和持久性 ( Durabilily )。关于事务最经典的示例莫过于信用卡转账:将用户 A 账户中的 500 元人民币转移到用户 B 的账户中,其操作流程如下 1. 将 A 账户中的金额减少 500 2. 将 B 账户中的金额增加 500 这两个操作必须保正 ACID 的事务属性:即要么全部成功,要么全部失败;假若没有事务保障,用户的账号金额将可能发生问题: 假如第一步操作成功而第二步失败,那么用户 A 账户中的金额将就减少 500 元而用户 B 的账号却没有任何增加(不翼而飞);同样如果第一步出错 而第二步成功,那么用户 A 的账户金额不变而用户 B 的账号将增加 500 元(凭空而生)。上述任何一种错误都会产生严重的数据不一致问题,事务的缺失对于一个稳定的生产系统是不可接受的。 J2EE 事务处理方式 1. 本地事务:紧密依赖于底层资源管理器(例如数据库连接 ),事务处理局限在当前事务资源内。此种事务处理方式不存在对应用服务器的依赖,因而部署灵活却无法支持多数据源的分布式事务。在数据库连接中使用本地事务示例如下: 清单 1. 本地事务处理实例 public void

XA/JTA transaction: JMS message arrives before DB changes are visible

亡梦爱人 提交于 2019-12-04 06:54:50
Context is: producer (JTA transaction PT ) is both sending message to JMS queue and making DB update; consumer (JTA transaction CT ) listens on same queue and reads DB when message is received; application server - WebLogic, DB - Oracle. I've observed, that sometimes CT is not (yet?) able to see DB changes of PT , event if corresponding JMS message is already received ( PT is committed?). It seems that JTA can't guarantee consistency of such kind (this was also confirmed in Jurgen Holler's presentation "Transaction Choices for Performance" ). What is the best way to avoid such problem (except

Spring/JTA/JPA DAO integration test doesn't rollback?

天涯浪子 提交于 2019-12-04 03:57:13
问题 My DAO integration tests are failing because entities created during the tests are still in the database at the start of the next test. The exact same behavior is seen from both MySQL 5 and H2. The test classes are annotated with: @Transactional @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration( { "/testPersist-applicationContext.xml" }) The transaction bean configuration in the test application context is as follows: <tx:annotation-driven /> <bean id="transactionManager" class=

How to get Hibernate configuration properties?

房东的猫 提交于 2019-12-04 01:48:55
问题 I`m using hibernate with jpa, and it is configured with persistence.xml Is it possible to get hibernate connection properties from web application? Thanks. 回答1: Probably not without using reflection and relying on the Hibernate not to break your code in the future. You need to get the properties from the SessionFactory but it's not public so you would have to find the Field via reflection, then use field.setAccessibleto get access to it. Something like: Field f = SessionFactoryImpl.class

Spring / JTA / JPA unit test : Rollback not working

萝らか妹 提交于 2019-12-04 01:32:38
问题 I am trying to test an entity EJB3 with Spring. The EJB itself does not uses Spring and I would like to keep duplications of the production JPA configuration minimal (ie not duplicating persistence.xml for exemple). My unit tests seems to work but even though my unit tests should be transactionnal, data is persisted between the various test methods ... Here is my entity : package sample; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.Id;

Last Resource Optimization

。_饼干妹妹 提交于 2019-12-03 22:45:49
问题 I'm writing a Resource Adaptor which does not support two phase commit. I know there is an optimization technique called: "Last Resource Optimization". On JBoss your XAResource class should implement LastResource in order to have the optimization. My question is: how this can be done in WebLogic, WebSpehre, Glassfish, etc... 回答1: Weblogic: AFAIK (may be very wrong) only JDBC drivers can be used with LRO, and it's a purely administrative task . When a driver doesn't support XA, it can be

Using arbitrary resources with JTA

二次信任 提交于 2019-12-03 20:08:25
Is it possible to make any type of custom resource transactioal with JTA? Let's assume a basic example and take a Folder creation that should be rolled back in case of an error. Can such custom resources be handled? Yes. That resource needs to provide an implementation of XAResource , and an instance of that implementation needs to be enlisted with the transaction when the resource is used. The resource can get the current transaction from the transaction manager in order to carry out the registration when it is accessed (i think). You could look at the code to XADisk , which is apparently an

Propagation of Oracle Transactions Between C++ and Java

感情迁移 提交于 2019-12-03 11:47:00
问题 We have an existing C++ application that we are going to gradually replace with a new Java-based system. Until we have completely reimplemented everything in Java we expect the C++ and Java to have to communicate with each other (RMI, SOAP, messaging, etc - we haven't decided). Now my manager thinks we'll need the Java and C++ sides to participate in the same Oracle DB transaction. This is related to, but different from the usual distrbuted transaction problem of having a single process co

Failed while installing JAX-RS (REST Web Services) 1.1. java.lang.NullPointerException

匿名 (未验证) 提交于 2019-12-03 08:39:56
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm working on an Acceleo project, when i generate a maven application, and update its dependencies, I get a pop up window that says: Failed while installing JAX-RS (REST Web Services) 1.1.java.lang.NullPointerException , I'm using Jersey. Same problem when I try to import it elsewhere. Any hints? thanks Error log !ENTRY org.eclipse.m2e.logback.appender 2 0 2013-05-30 15:02:13.572 !MESSAGE The artifact jta:jta:jar:1.0.1b has been relocated to javax.transaction:jta:jar:1.0.1B !ENTRY org.eclipse.m2e.logback.appender 2 0 2013-05-30 15:02:13.807