• 关于atomikos分布式事务的经验 oracle 版本


    pom配置:

    <properties>

    <atomikos.version>3.9.3</atomikos.version>

    <spring.version>4.2.5.RELEASE</spring.version>

    </properties>

    <dependency>
                <groupId>com.atomikos</groupId>
                <artifactId>transactions-jdbc</artifactId>
                <version>${atomikos.version}</version>
            </dependency>
            <dependency>
                <groupId>com.atomikos</groupId>
                <artifactId>transactions-jta</artifactId>
                <version>${atomikos.version}</version>
            </dependency>
            <dependency>
                <groupId>com.atomikos</groupId>
                <artifactId>transactions</artifactId>
                <version>${atomikos.version}</version>
            </dependency>
            <dependency>
                <groupId>com.atomikos</groupId>
                <artifactId>transactions-api</artifactId>
                <version>${atomikos.version}</version>
            </dependency>
            <dependency>
                <groupId>com.atomikos</groupId>
                <artifactId>atomikos-util</artifactId>
                <version>${atomikos.version}</version>
            </dependency>
            <dependency>
                <groupId>javax.transaction</groupId>
                <artifactId>jta</artifactId>
                <version>1.1</version>
            </dependency>

    <!-- JDBC Driver。Oracle JDBC驱动必须从官网下载,然后使用 mvn install:install-file -DgroupId=com.oracle
                -DartifactId=ojdbc6 -Dversion=11.2.0.3.0 -Dpackaging=jar -Dfile=ojdbc6.jar
                -DgeneratePom=true命令安装到本地Maven仓库 -->
            <dependency>
                <groupId>com.oracle</groupId>
                <artifactId>ojdbc6</artifactId>
                <version>11.2.0.3.0</version>

               <!-- <scope>provided</scope> 这个要去掉,不然运行不起来-->

            </dependency>

    spring配置:



            <!-- oracle数据源 -->
       <bean id="dataSource" class="com.atomikos.jdbc.AtomikosDataSourceBean"
            init-method="init" destroy-method="close">
            <property name="uniqueResourceName">
                <value>oracle_dataSourceaaaabbb</value>
            </property>
            <property name="xaDataSourceClassName">
                <value>oracle.jdbc.xa.client.OracleXADataSource</value>
            </property>
            <property name="xaProperties">
                <props>
                   <prop key="URL">jdbc:oracle:thin:@127.0.0.1:1521:orcl</prop>  
                     <prop key="user">nec</prop>  
                     <prop key="password">1111</prop>
                </props>
            </property>
            <property name="minPoolSize" value="10" />  
                <property name="maxPoolSize" value="100" />  
                <property name="borrowConnectionTimeout" value="300" />  
        </bean>
            <bean id="basicDataSource" class="com.atomikos.jdbc.AtomikosDataSourceBean"
            init-method="init" destroy-method="close">
            <property name="uniqueResourceName">
                <value>oracle_dataSource_basic</value>
            </property>
            <property name="xaDataSourceClassName">
                <value>oracle.jdbc.xa.client.OracleXADataSource</value>
            </property>
            <property name="xaProperties">
                <props>
                    <prop key="URL">jdbc:oracle:thin:@127.0.0.1:1521:orcl</prop>  
                     <prop key="user">basic</prop>  
                     <prop key="password">1111</prop>
                </props>
            </property>
            <property name="minPoolSize" value="10" />  
                <property name="maxPoolSize" value="100" />  
                <property name="borrowConnectionTimeout" value="300" />  
        </bean>

            
            <bean id="userTransactionService" class="com.atomikos.icatch.config.UserTransactionServiceImp"
                init-method="init" destroy-method="shutdownForce">
            <constructor-arg>
                <props>
                    <prop key="com.atomikos.icatch.service">com.atomikos.icatch.standalone.UserTransactionServiceFactory</prop>
                </props>
            </constructor-arg>
            </bean>
        
            <bean id="atomikosTransactionManager" class="com.atomikos.icatch.jta.UserTransactionManager"
            init-method="init" destroy-method="close" depends-on="userTransactionService">
                <property name="forceShutdown" value="false" />
            </bean>
        
            <bean id="atomikosUserTransaction" class="com.atomikos.icatch.jta.UserTransactionImp" depends-on="userTransactionService">
                <property name="transactionTimeout" value="300" />
            </bean>
             
             <bean id="xaManager" class="org.springframework.transaction.jta.JtaTransactionManager"  depends-on="userTransactionService">
               <property name="transactionManager" ref="atomikosTransactionManager"/>  
               <property name="userTransaction" ref="atomikosUserTransaction"/>  
               </bean>
        <tx:annotation-driven transaction-manager="xaManager" /> <!-- 事务注解-->

    以下内容为jboss jndi配置失败,原因不明,郁闷啊,如果有高手路过,请不吝赐教

    jboss 配置:

    <xa-datasource jta="true" jndi-name="java:jboss/datasources/NecDS" pool-name="NecDS" enabled="true"  use-ccm="false">
                        <xa-datasource-property name="URL">
                            jdbc:oracle:thin:@127.0.0.1:1521:orcl
                        </xa-datasource-property>
                        <xa-datasource-property name="User">
                            nec
                        </xa-datasource-property>
                        <xa-datasource-property name="Password">
                            1111
                        </xa-datasource-property>
                        <xa-datasource-class>oracle.jdbc.xa.client.OracleXADataSource</xa-datasource-class>
                        <driver>oracle</driver>
                        <transaction-isolation>TRANSACTION_READ_COMMITTED</transaction-isolation>
                        <xa-pool>
                            <min-pool-size>20</min-pool-size>
                            <max-pool-size>100</max-pool-size>
                        </xa-pool>
                        <security>
                            <user-name>nec</user-name>
                            <password>vnetoo</password>
                        </security>
                        <validation>
                            <check-valid-connection-sql>select 1 from dual</check-valid-connection-sql>
                            <validate-on-match>false</validate-on-match>
                            <background-validation>false</background-validation>
                        </validation>
                        <statement>
                            <prepared-statement-cache-size>32</prepared-statement-cache-size>
                            <share-prepared-statements>true</share-prepared-statements>
                        </statement>
                    </xa-datasource>

    spring配置:

    <jee:jndi-lookup id="dataSource" jndi-name="${jndi.dataSource}"/>

  • 相关阅读:
    Days like that:
    获取网站访问来源URL
    论坛里面的一个帖子
    Days like that:
    简单项目布署
    论坛里面的一个帖子
    获取网站访问来源URL
    piwik开放源代码的Web统计软件
    p标签里面不能嵌套div
    IO操作 第二篇 学习(转载)
  • 原文地址:https://www.cnblogs.com/lingepeiyong/p/2302184.html
Copyright © 2020-2023  润新知