使用Atomikos Transactions Essentials实现多数据源JTA分布式事务
来源:互联网 发布:中国或成最大输家知乎 编辑:程序博客网 时间:2024/05/16 10:16
- <!-- 第一个数据库 -->
- < bean id = "dataSource" class = "com.atomikos.jdbc.SimpleDataSourceBean" init-method = "init" destroy-method = "close" >
- < property name = "uniqueResourceName" >
- < value > mysql/main </ value >
- </ property >
- < property name = "xaDataSourceClassName" >
- <!-- 使用Mysql XADataSource(mysql>=5.0, Connector/J>=5.0才可以支持XADatasource)-->
- < value > com.mysql.jdbc.jdbc2.optional.MysqlXADataSource </ value >
- </ property >
- < property name = "xaDataSourceProperties" >
- < value > URL =${jdbc.url}; user =${jdbc.username}; password =${jdbc.password} </ value >
- </ property >
- < property name = "exclusiveConnectionMode" >
- < value > true </ value >
- </ property >
- < property name = "connectionPoolSize" >
- < value > 3 </ value >
- </ property >
- < property name = "validatingQuery" >
- < value > SELECT 1 </ value >
- </ property >
- </ bean >
- <!-- 第二个数据库 -->
- < bean id = "dataSourceB" class = "com.atomikos.jdbc.SimpleDataSourceBean" init-method = "init" destroy-method = "close" >
- < property name = "uniqueResourceName" >
- < value > mysql/news </ value >
- </ property >
- < property name = "xaDataSourceClassName" >
- <!-- 使用Mysql XADataSource(mysql>=5.0, Connector/J>=5.0才可以支持XADatasource)-->
- < value > com.mysql.jdbc.jdbc2.optional.MysqlXADataSource </ value >
- </ property >
- < property name = "xaDataSourceProperties" >
- < value > URL =${jdbc.url.b}; user =${jdbc.username.b}; password =${jdbc.password.b} </ value >
- </ property >
- < property name = "exclusiveConnectionMode" >
- < value > true </ value >
- </ property >
- < property name = "connectionPoolSize" >
- < value > 3 </ value >
- </ property >
- < property name = "validatingQuery" >
- < value > SELECT 1 </ value >
- </ property >
- </ bean >
- < bean id = "lobHandler" class = "org.springframework.jdbc.support.lob.DefaultLobHandler" />
- <!-- 第一个数据库的sqlMapClient -->
- < bean id = "sqlMapClient" class = "org.springframework.orm.ibatis.SqlMapClientFactoryBean" >
- < property name = "configLocation" >
- <!-- 包含第一个数据库表的map -->
- < value > classpath:/sqlmap-config.xml </ value >
- </ property >
- < property name = "dataSource" ref = "dataSource" />
- < property name = "lobHandler" ref = "lobHandler" />
- </ bean >
- <!-- 第二个数据库的sqlMapClient -->
- < bean id = "sqlMapClientB" class = "org.springframework.orm.ibatis.SqlMapClientFactoryBean" >
- < property name = "configLocation" >
- <!-- 包含第一个数据库表的map -->
- < value > classpath:/sqlmap-configb.xml </ value >
- </ property >
- < property name = "dataSource" ref = "dataSourceB" />
- < property name = "lobHandler" ref = "lobHandler" />
- </ bean >
- <!-- Construct Atomikos UserTransactionManager, needed to configure Spring -->
- < bean id = "atomikosTransactionManager" class = "com.atomikos.icatch.jta.UserTransactionManager" init-method = "init"
- destroy-method = "close" >
- <!-- when close is called, should we force transactions to terminate or not? -->
- < property name = "forceShutdown" >
- < value > true </ value >
- </ property >
- </ bean >
- <!-- Also use Atomikos UserTransactionImp, needed to configure Spring -->
- < bean id = "atomikosUserTransaction" class = "com.atomikos.icatch.jta.UserTransactionImp" >
- < property name = "transactionTimeout" value = "240" />
- </ bean >
- <!-- Configure the Spring framework to use JTA transactions from Atomikos -->
- < bean id = "transactionManager" class = "org.springframework.transaction.jta.JtaTransactionManager" >
- < property name = "transactionManager" >
- < ref bean = "atomikosTransactionManager" />
- </ property >
- < property name = "userTransaction" >
- < ref bean = "atomikosUserTransaction" />
- </ property >
- </ bean >
事务的配置, 使用了spring2.0的语法,所以将namesapce也帖出来了.
xml 代码
- <? xml version = "1.0" encoding = "UTF-8" ?>
- < beans xmlns = "http://www.springframework.org/schema/beans"
- xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance"
- xmlns:aop = "http://www.springframework.org/schema/aop"
- xmlns:tx = "http://www.springframework.org/schema/tx"
- xsi:schemaLocation ="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
- http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
- http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd"
- default-autowire = "byName" default-lazy-init = "true" >
- <!-- 支持 @AspectJ 标记-->
- < aop:aspectj-autoproxy />
- < aop:config proxy-target-class = "true" >
- < aop:advisor pointcut = "execution(* *Facade.*(..))" advice-ref = "txAdvice" />
- < aop:advisor pointcut = "execution(* *Manager.*(..))" advice-ref = "txAdvice" />
- </ aop:config >
- < tx:advice id = "txAdvice" >
- < tx:attributes >
- < tx:method name = "get*" read-only = "true" />
- < tx:method name = "find*" read-only = "true" />
- < tx:method name = "has*" read-only = "true" />
- < tx:method name = "locate*" read-only = "true" />
- < tx:method name = "*" />
- </ tx:attributes >
- </ tx:advice >
- </ beans >
- 使用Atomikos Transactions Essentials实现多数据源JTA分布式事务
- 使用Atomikos Transactions Essentials实现多数据源JTA分布式事务
- 使用Atomikos Transactions Essentials实现多数据源JTA分布式事务
- spring atomikos 实现多数据源 分布式事务
- atomikos实现多数据源支持分布式事务管理(spring、tomcat、JTA)
- 分布式事务JTA实现之:SSM+ATOMIKOS
- Springboot+atomikos+jta实现分布式事务统一管理
- 多数据源 atomikos 打造Java分布式事务
- Spring Boot Druid 多数据源 Atomikos 分布式事务
- JTA分布式事务实战(atomikos)
- Spring多数据源分布式事务管理/springmvc+spring+atomikos[jta]+druid+mybatis
- Spring多数据源分布式事务管理/springmvc+spring+atomikos[jta]+druid+mybatis
- Spring多数据源分布式事务管理/springmvc+spring+atomikos[jta]+druid+mybatis
- java分布式事务(JTA)实现 jotm和atomikos
- java分布式事务(JTA)实现 jotm和atomikos
- Postgresql 分布式事务JTA实现Atomikos与Spring集成实践
- Spring JTA接口+Atomikos实现申明式分布式事务控制
- Spring3.0+Hibernate+Atomikos集成构建JTA的分布式事务--解决多数据源跨库事务
- 使用JOTM实现分布式事务管理(多数据源)
- 爱度珠宝实习总结
- 一个自定义属性(Attribute)的Demo
- 真正的电脑高手是不用鼠标的 全键盘 你知道几个?
- 未来五年程序员应当具备的十项技能
- 使用Atomikos Transactions Essentials实现多数据源JTA分布式事务
- 拓展人脉的老派艺术
- Visual Studio 2005 Windows Forms Controls List
- 优秀程序员的十个习惯
- perl ide集成开发环境整理大全
- N年后,我又回到了CSDN
- 关于佛教都市
- 识人、用人、激人、留人、斩人
- IComparable and IComparer