Linux安全网 - Linux操作系统_Linux 命令_Linux教程_Linux黑客

绿色网站无广告
会员投稿 投稿指南 本期推荐:
搜索:
您的位置: Linux安全网 > Linux集群 > Architecture > » 正文

spring+atomikos 跨库事务配置

来源: 未知 分享至:

<bean id="dataSourceA" class="com.atomikos.jdbc.AtomikosDataSourceBean" init-method="init" destroy-method="close">
<property name="uniqueResourceName" value="mysql/merchant" />
<property name="xaDataSourceClassName" value="com.mysql.jdbc.jdbc2.optional.MysqlXADataSource" />
<property name="xaProperties">
<props>
<prop key="user">root</prop>
<prop key="password">wait4you</prop>
<prop key="url">jdbc:mysql://10.0.10.24:3306/merchant?useUnicode=true&amp;characterEncoding=utf-8</prop>
</props>

</property>
<property name="poolSize" value="10"/>
<property name="testQuery" value="SELECT 1"/>
</bean>


<bean id="dataSourceB" class="com.atomikos.jdbc.AtomikosDataSourceBean" init-method="init" destroy-method="close">
<property name="uniqueResourceName" value="mysql/orders" />
<property name="xaDataSourceClassName" value="com.mysql.jdbc.jdbc2.optional.MysqlXADataSource" />
<property name="xaProperties">
<props>
<!--prop key="user">root</prop>
<prop key="password">wait4you</prop-->
<prop key="user">specl</prop>
<prop key="password">uBpEaNEI5</prop>
<prop key="url">jdbc:mysql://10.0.10.34:3306/orders?useUnicode=true&amp;characterEncoding=utf-8</prop>
</props>

</property>
<property name="poolSize" value="10"/>
<property name="testQuery" value="SELECT 1"/>
</bean>

<bean id="dataSource" class="com.specl.api.sharding.DynamicDataSource">
<property name="targetDataSources">
<map key-type="java.lang.String">
<entry key="order_r_0" value-ref="dataSourceB" />
<entry key="order_rw_0" value-ref="dataSourceB" />
<entry key="merchant_r_0" value-ref="dataSourceA" />
<entry key="merchant_rw_0" value-ref="dataSourceA" />
</map>
</property>
<property name="defaultTargetDataSource" ref="dataSourceA"/>
</bean>

<bean id="sqlMapClient" class="org.springframework.orm.ibatis.SqlMapClientFactoryBean">
<property name="configLocation" value="classpath:sqlmap-config.xml" />
<property name="dataSource" ref="dataSource" />
</bean>

<bean id="atomikosTransactionManager" class="com.atomikos.icatch.jta.UserTransactionManager" init-method="init" destroy-method="close">
<property name="forceShutdown">
<value>true</value>
</property>
</bean>
<bean id="atomikosUserTransaction" class="com.atomikos.icatch.jta.UserTransactionImp">
<property name="transactionTimeout" value="300" />
</bean>

<bean id="jtaTransactionManager" class="org.springframework.transaction.jta.JtaTransactionManager">
<property name="transactionManager">
<ref bean="atomikosTransactionManager" />
</property>
<property name="userTransaction">
<ref bean="atomikosUserTransaction" />
</property>
<qualifier value="jtaTx"></qualifier>
</bean>

<bean id="singleTransactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSourceA"/>
<qualifier value="singleTx"></qualifier>
</bean>

<bean id="boardDao" class="com.specl.api.dao.release.BoardDaoRelease">
<property name="sqlMapClient" ref="sqlMapClient"></property>
</bean>


Tags:
分享至:
最新图文资讯
1 2 3 4 5 6
验证码:点击我更换图片 理智评论文明上网,拒绝恶意谩骂 用户名:
关于我们 - 联系我们 - 广告服务 - 友情链接 - 网站地图 - 版权声明 - 发展历史