How do I configure Tomcat support JTA?

Source: Internet
Author: User
Tags auth sybase sybase database
First you need to [install components that can use JTA, and the components you can use include Atomikos, jbossts, OPENEJB

In Atomikos, the Sybase database is used to illustrate:
(1). Atomikos Configuration
Jta.properties, please refer to Atomikos's documentation for configuration

(2). Spring Configuration
<tx:jta-transaction-manager/>
<tx:annotation-driven/>

<!--DB-->
<bean id= "Atii.datasource" class= "Org.springframework.jndi.JndiObjectFactoryBean" >
<property name= "Jndiname" value= "Jdbc/atii"/>
<property name= "Resourceref" value= "${isresourceref}"/>
</bean>

<!--JMS Sender-->
<bean id= "Atii.jmsconnfactory" class= "Org.springframework.jndi.JndiObjectFactoryBean" >
<property name= "Jndiname" value= "Jms/topicconnfactory"/>
<property name= "Resourceref" value= "${isresourceref}"/>
</bean>
<bean id= "Atii.jmstopic" class= "Org.springframework.jndi.JndiObjectFactoryBean" >
<property name= "Jndiname" value= "Jms/topic"/>
<property name= "Resourceref" value= "${isresourceref}"/>
</bean>
<bean id= "Atii.jmstemplate" class= "Org.springframework.jms.core.JmsTemplate" >
<property name= "ConnectionFactory" ref= "Atii.jmsconnfactory"/>
<property name= "defaultdestination" ref= "Atii.jmstopic"/>
<property name= "sessiontransacted" value= "true"/>
</bean>

<!--JMS receiver-->
<bean id= "Atii.messagelistener" class= "Org.springframework.jms.listener.adapter.MessageListenerAdapter" >
<property name= "Delegate" ref= "Atii.systeminfoservice"/>
<property name= "Defaultlistenermethod" value= "Receive"/>
</bean>
<bean id= "Atii.messagelistenercontainer" class= " Org.springframework.jms.listener.DefaultMessageListenerContainer ">
<property name= "ConnectionFactory" ref= "Atii.jmsconnfactory"/>
<property name= "Destination" ref= "Atii.jmstopic"/>
<property name= "MessageListener" ref= "Atii.messagelistener"/>
<property name= "Autostartup" value= "true"/>
<property name= "TransactionManager" ref= "TransactionManager"/>
<property name= "sessiontransacted" value= "true"/>
</bean>

(3). Tomcat Configuration
Contex.xml Configuration
<transaction factory= "Com.atomikos.icatch.jta.UserTransactionFactory"/>

<!--database configuration to use JDBC drivers that implement Xadatasource-->
<resource name= "jdbc/atii" auth= "Container" type= "Com.atomikos.jdbc.AtomikosDataSourceBean"
factory= "Com.atomikos.tomcat.BeanFactory" uniqueresourcename= "Jdbc/atii"
Xadatasourceclassname= "Com.sybase.jdbc3.jdbc.SybXADataSource"
testquery= "SELECT 1"
Minpoolsize= "1"
Maxpoolsize= "2"
Xaproperties.databasename= "Atii"
Xaproperties.servername= "10.233.7.186"
Xaproperties.portnumber= "5000"
Xaproperties.user= "Login_name"
xaproperties.password= "Password"
xaproperties.jconnect_version= "6.05"
xaproperties.charset= "cp936"
Xaproperties.dynamic_prepare= "true"/>

<!--Message Queuing configuration requires the connection factory with Xaconnectionfactory implemented-->
<resource name= "Jms/topicconnfactory" auth= "Container" type= "Com.atomikos.jms.AtomikosConnectionFactoryBean"
factory= "Com.atomikos.tomcat.EnhancedTomcatAtomikosBeanFactory" uniqueresourcename= "Jms/topicconnfactory"
Xaconnectionfactoryclassname= "Org.apache.activemq.ActiveMQXAConnectionFactory"
Xaproperties.brokerurl= "tcp://localhost:61616"
Maxpoolsize= "3"
minpoolsize= "1"/>

<resource name= "Jms/topic" auth= "Container" type= "Org.apache.activemq.command.ActiveMQTopic"
factory= "Org.apache.naming.factory.BeanFactory"
Physicalname= "Testtopic"/>

Adding Atomikos-lifecycle-listener.jar,atomikos-tomcat-beanfactory.jar to the common.loader of Catalina.properties, Atomikos-transactions-3.7.0.jar, and other related jar files;
Join Jta.properties Path

Server.xml Configuration
<listener classname= "Com.atomikos.tomcat.AtomikosLifecycleListener"/>

(4). Sybase Related Configuration
Sp_role "Grant", Dtm_tm_role,login_name

sp_configure ' Enable DTM ', 1
sp_configure ' enable XACT coordination ', 1

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.