码迷,mamicode.com
首页 > 编程语言 > 详细

Spring with and without XA

时间:2015-08-04 21:15:19      阅读:184      评论:0      收藏:0      [点我收藏+]

标签:

http://www.javaworld.com/article/2077963/open-source-tools/distributed-transactions-in-spring--with-and-without-xa.html

文章涉及的代码:


1.

	<bean id="transactionManager"
		class="org.springframework.transaction.jta.JtaTransactionManager">
		<property name="transactionManager">
			<bean class="com.atomikos.icatch.jta.UserTransactionManager"
				init-method="init" destroy-method="close">
				<property name="forceShutdown">
					<value>true</value>
				</property>
				<property name="transactionTimeout">
					<value>600</value>
				</property>
			</bean>
		</property>
		<property name="userTransaction">
			<bean class="com.atomikos.icatch.jta.UserTransactionImp" />
		</property>
	</bean>
	
		<bean id="dataSource" class="com.springsource.open.db.AtomikosDataSourceFactoryBean">
		<property name="uniqueResourceName" value="data-source" />
		<property name="xaDataSource">
			<bean class="test.jdbc.datasource.DerbyDataSourceFactoryBean">
				<property name="databaseName" value="derbydb" />
			</bean>
		</property>
		<property name="exclusiveConnectionMode" value="true" />
		<property name="connectionPoolSize" value="1" />
	</bean>

	<bean id="otherDataSource" class="com.springsource.open.db.AtomikosDataSourceFactoryBean">
		<property name="uniqueResourceName" value="other-data-source" />
		<property name="xaDataSource">
			<bean class="test.jdbc.datasource.DerbyDataSourceFactoryBean">
				<property name="databaseName" value="otherdb" />
			</bean>
		</property>
		<property name="exclusiveConnectionMode" value="true" />
		<property name="connectionPoolSize" value="1" />
	</bean>

2.

	<bean id="brokerService" class="org.apache.activemq.broker.BrokerService"
		init-method="start" destroy-method="stop">
		<property name="brokerName" value="broker" />
		<!-- Enable this if you need to inspect with JMX -->
		<property name="useJmx" value="false" />
		<property name="transportConnectorURIs">
			<list>
				<value>vm://localhost</value>
			</list>
		</property>
		<property name="persistenceAdapter">
			<bean class="org.apache.activemq.store.jdbc.JDBCPersistenceAdapter">
				<property name="dataSource">
					<bean class="com.springsource.open.jms.JmsTransactionAwareDataSourceProxy">
						<property name="targetDataSource" ref="dataSource"/>
						<property name="jmsTemplate" ref="jmsTemplate"/>
					</bean>
				</property>
				<property name="createTablesOnStartup" value="true" />
			</bean>
		</property>
	</bean>


3.  

	<bean id="connectionFactory"
		class="org.springframework.jms.connection.TransactionAwareConnectionFactoryProxy">
		<property name="targetConnectionFactory">
			<bean class="org.apache.activemq.ActiveMQConnectionFactory" depends-on="brokerService">
				<property name="brokerURL" value="vm://localhost"/>
			</bean>
		</property>
		<property name="synchedLocalTransactionAllowed" value="true" />
	</bean>


Spring with and without XA

标签:

原文地址:http://my.oschina.net/frankies/blog/487720

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!