您现在的位置是:首页 > 电脑 > 

Atomikos中文说明文档

2025-07-22 00:55:29
Atomikos中文说明文档 Atomikos 翻译文档(英文文档来源:下载安装包中START_HERE.html)                                  ----译者:周枫 请尊重劳动成果,转载请标明,英语水平有限,如有不准确地方请在评论中指出,谢谢

Atomikos中文说明文档

Atomikos 翻译文档(英文文档来源:下载安装包中START_HERE.html)

                                 ----译者:周枫

请尊重劳动成果,转载请标明,英语水平有限,如有不准确地方请在评论中指出,谢谢

地址:

使用版本:AtomikosTransactiEssentials-.7.2

感谢您使用Atomikos,下面的说明文档可以让您正确使用,如果您有任何问题或者反馈,请访问我们的帮助网页,或者给我们发送邮件sales@atomikos。

什么是Atomikos TransactiEssentials

         Atomikos TransactiEssentials 是一个为Java平台提供增值服务的并且开源类事务管理器,以下是包括在这个开源版本中的一些功能:

l  全面崩溃 / 重启恢复

l  兼容标准的SU公司JTA API

l  嵌套事务

l  为XA和非XA提供内置的JDBC适配器

注释:XA:XA协议由Tuxedo首先提出的,并交给X/Open组织,作为资源管理器(数据库)与事务管理器的接口标准。目前,Oracle、Informix、DB2和Sybase等各大数据库厂家都提供对XA的支持。XA协议采用两阶段提交方式来管理分布式事务。XA接口提供资源管理器与事务管理器之间进行通信的标准接口。XA协议包括两套函数,以xa_开头的及以ax_开头的。

以下的函数使事务管理器可以对资源管理器进行的操作:

  1)xa_open,xa_close:建立和关闭与资源管理器的连接。

  2)xa_start,xa_end:开始和结束一个本地事务。

  )xa_prepare,xa_commit,xa_rollback:预提交、提交和回滚一个本地事务。

  4)xa_recover:回滚一个已进行预提交的事务。

  5)ax_开头的函数使资源管理器可以动态地在事务管理器中进行注册,并可以对XID(TRASACTIO IDS)进行操作。

  6)ax_reg,ax_unreg;允许一个资源管理器在一个TMS(TRASACTIO MAAGER SERVER)中动态注册或撤消注册。

l  内置的JMS适配器XA-capable JMS队列连接器

注释:JMS:jms即Java消息服务(Java Message Service)应用程序接口是一个Java平台中关于面向消息中间件(MOM)的API,用于在两个应用程序之间,或分布式系统中发送消息,进行异步通信。Java消息服务是一个与具体平台无关的API,绝大多数MOM提供商都对JMS提供支持。

l  通过XA API兼容第三方适配器

l  更好的整合您的项目

l  集成Hibernate

如何使用Atomikos TransactiEssentials

         Atomikos TransactiEssentials 是一个可靠的库,可以加入到您的Java应用程序,也就是说为了使用这个产品,您必须添加一些jar文件(包括在dist和lib文件夹下)到您的应用程序或者应用程序服务器。

         请注意:Atomikos TransactiEssentials是一个非常快速的嵌入式事务管理器,这就意味着,您不需要另外启动一个单独的事务管理器进程(不要查任何的bin文件夹)。相反,您的应用服务器将有它自己的intra-VM事务管理器。

         配置需求:至少Java1.5 jdk,并且最少128M的内存

         性能优化:尽管这个软件有着很大的优势,但是想要更好的发挥其作用,可以按以下的方法优化:

l  更高的内存,意味着更高的吞吐量(每秒的事务数目)

l  使连接池尽可能的大

l  一旦你不需要的连接请马上关闭它们。不要把你的应用程序放在缓存里,让内部连接池为你做这些,这将促使更高效的连接使用

l  不要让活动的事务闲置:终止所有情况下的事务,尤其是在异常报错情况下的事务。这将减少数据库的锁定时间,并且最大效率的处理启用的使用。

如果想获取这些细节的更多信息,也要参阅文档说明部分。

值得注意的是,在我们所有的压力测试中,Atomikos TransactiEssentials比J2EE的web容器更高效的吞吐量。这些测量值包括日志记录的高效的事务状态,同样,在我们所有的测量中,包括XA和non-XA,高效的效率是一样的。

         在J2SE中使用Atomikos Transacti Essentials,只需要按以下步骤

  1. 将idst和lib中的jar包全部放入的项目中
  2. 创建或者自定义你应用的transacti.properties(或者jta.properties)文件(事务管理器的配置),然后将它放入到classpath中,安装文件夹中包涵一个实例文件;在properties文件中注释(#)后面的是默认值,取消一行并且改变默认值。
    # SAMPLE PROPERTIES FILE FOR THE TRASACTIO SERVICE
    # THIS FILE ILLUSTRATES THE DIFFERET SETTIGS FOR THE TRASACTIO MAAGER
    # UCOMMET THE ASSIGMETS TO OVERRIDE DEFAULT VALUES;# Required: factory implementation class of the transaction core.
    # OTE: there is no default for this, so it MUST be specified! 
    # 
    com.atomikos.icatch.service=com.atomikos.icatch.standalone.UserTransactionServiceFactory# Set base name of file where messages are output 
    # (also known as the 	cole file	).
    #
    # com.atomikos._file_name = # Size limit (in bytes) for the cole file;
    # negative means unlimited.
    #
    # com.atomikos._file_limit=-1# For size-limited cole files, this option
    # specifies a number of rotating files to 
    # maintain.
    #
    # com.atomikos._file_count=1# Set the number of log writes between checkpoints
    #
    # com.atomikos._interval=500# Set output directory where cole file and other files are to be put
    # make sure this directory exists!
    #
    # com.atomikos._dir = ./# Set directory of log files; make sure this directory exists!
    #
    # com.atomikos.icatch.log_base_dir = ./# Set base name of log file
    # this name will be  used as the first part of 
    # the system-generated log file name
    #
    # com.atomikos.icatch.log_base_name = tmlog# Set the max number of active local transacti 
    # or -1 for unlimited.
    #
    # com.atomikos._actives = 50# Set the default timeout (in milliseconds) for local transacti
    #
    # com.atomikos.icatch.default_jta_timeout = 10000# Set the max timeout (in milliseconds) for local transacti
    #
    # com.atomikos._timeout = 00000# The globally unique name of this transaction manager process
    # override this value with a globally unique name
    #
    # com.atomikos._unique_name = tm# Do we want to use parallel subtransacti? JTA	s default
    # is O for J2EE compatibility
    #
    # com.atomikos.icatch.serial_jta_transacti=true# If you want to do explicit resource registration then
    # you need to set this value to false.
    #
    # com.atomikos.icatch.automatic_resource_registration=true  # Set this to WAR, IFO or DEBUG to control the granularity
    # of output to the cole file.
    #
    # com.atomikos._log_level=WAR# Do you want transaction logging to be enabled or not?
    # If set to false, then no logging overhead will be done
    # at the risk of losing data after restart or crash.
    #
    # com.atomikos._logging=true# Should two-phase commit be done in (multi-)threaded mode or not?
    # Set this to false if you want commits to be ordered according
    # to the order in which resources are added to the transaction.
    #
    # OTE: threads are reused on JDK 1.5 or higher. 
    # For JDK 1.4, thread reuse is enabled as soon as the 
    # concurrent backport is in the classpath - see 
    # /
    #
    # com.atomikos._2pc=false# Should shutdown of the VM trigger shutdown of the transaction core too?
    #
    # com.atomikos.icatch.force_shutdown_on_vm_exit=false

     

  3. 在你的应用程序中,创建一个实例com.atomikos.icatch.jta.UserTransactionImp或者com.atomikos.icatch.jta.UserTransactionManager(使用默认的无参数构造函数)
    /*** Copyright (C) 2000-2010 Atomikos <info@atomikos>** This code (Atomikos TransactiEssentials), by itself,* is being distributed under the* Apache License, Version 2.0 (License), a copy of which may be found at* . .* You may not use this file except in compliance with the License.** While the License grants certain patent license rights,* those patent license rights only extend to the use of* Atomikos TransactiEssentials by itself.** This code (Atomikos TransactiEssentials) contains certain interfaces* in package (namespace) com.atomikos.icatch* (including com.atomikos.icatch.Participant) which, if implemented, may* infringe one or more patents held by Atomikos.* It should be appreciated that you may OT implement such interfaces;* licensing to implement these interfaces must be obtained separately from Atomikos.** Unless required by applicable law or agreed to in writing, software* distributed under the License is distributed on an AS IS BASIS,* WITHOUT WARRATIES OR CODITIOS OF AY KID, either express or implied.*/package com.atomikos.icatch.jta;import java.io.Serializable;import amingException;
    import Reference;
    import Referenceable;
    import ;
    import SystemException;
    import TransactionManager;
    import UserTransaction;import com.atomikos.icatch.admin.imp.SimpleLogAdministrator;
    import com.atomikos.TSInitInfo;
    import com.atomikos.UserTransactionService;
    import com.atomikos.UserTransactionServiceImp;
    import com.atomikos.util.SerializableObjectFactory;/*** * * Our UserTransaction implementation for J2SE transacti. This class is* special in that it automatically starts up and recover the transaction* service on first use. <b>ote: don	t use this class in J2EE applicati in* order to avoid starting different transaction engines in the same application* server! J2EE applicati should use J2eeUserTransaction instead.</b>*/public class UserTransactionImp implements UserTransaction, Serializable,Referenceable
    {private transient TransactionManager txmgr_;/*** o-argument ctructor.*/public UserTransactionImp (){}/*** Referenceable mechanism requires later setup of txmgr_, otherwise binding* into JDI already requires that TM is running.*/private void checkSetup (){// REMOVED FOLLOWIG IF CHECK: DO	T CACHE THE TXMGR TO MAKE ISTACES// RESILIET TO RESTART I TOMCAT. OTHERWISE, CLIET APPS SEE THEIR// USERTX REFERECES IVALIDATED AD THIS IS ITOLERABLE// if ( txmgr_ == null ) {// txmgr_ = TransactionManagerImp.getTransactionManager();synchronized (  ) {txmgr_ = TransactionManagerImp.getTransactionManager ();// FOLLOWIG COMMETED OUT: EW RECOVERY I 2.0 ALLOWS US TO START// THE TM// IF OT ALREADY RUIG!!!// if ( txmgr_ == null )// throw new RuntimeException ( o transaction monitor installed?// );// EW FROM 2.0: if TM is not running, just start it. Any resources// can be registered later.if ( txmgr_ == null ) {UserTransactionService uts = new UserTransactionServiceImp ();TSInitInfo info =  ();uts.registerLogAdministrator ( SimpleLogAdministrator.getInstance () );uts.init ( info );txmgr_ = TransactionManagerImp.getTransactionManager ();}}// }
        }/*** @see UserTransaction*/public void begin () throws otSupportedException, SystemException{checkSetup ();txmgr_.begin ();}/*** @see UserTransaction*/public void commit () throws RollbackException,HeuristicMixedException,HeuristicRollbackException,SystemException, java.lang.IllegalStateException,java.lang.SecurityException{checkSetup ();txmgr_mit ();}/*** @see UserTransaction*/public void rollback () throws IllegalStateException, SystemException,SecurityException{checkSetup ();txmgr_.rollback ();}/*** @see UserTransaction*/public void setRollbackOnly () throws IllegalStateException,SystemException{checkSetup ();txmgr_.setRollbackOnly ();}/*** @see UserTransaction*/public int getStatus () throws SystemException{checkSetup ();return txmgr_.getStatus ();}/*** @see UserTransaction*/public void setTransactionTimeout ( int seconds ) throws SystemException{checkSetup ();txmgr_.setTransactionTimeout ( seconds );}////// IMPLEMETATIO OF REFERECEABLE////
    public Reference getReference () throws amingException{return  ( this );}
    }
    /*** Copyright (C) 2000-2010 Atomikos <info@atomikos>** This code (Atomikos TransactiEssentials), by itself,* is being distributed under the* Apache License, Version 2.0 (License), a copy of which may be found at* . .* You may not use this file except in compliance with the License.** While the License grants certain patent license rights,* those patent license rights only extend to the use of* Atomikos TransactiEssentials by itself.** This code (Atomikos TransactiEssentials) contains certain interfaces* in package (namespace) com.atomikos.icatch* (including com.atomikos.icatch.Participant) which, if implemented, may* infringe one or more patents held by Atomikos.* It should be appreciated that you may OT implement such interfaces;* licensing to implement these interfaces must be obtained separately from Atomikos.** Unless required by applicable law or agreed to in writing, software* distributed under the License is distributed on an AS IS BASIS,* WITHOUT WARRATIES OR CODITIOS OF AY KID, either express or implied.*/package com.atomikos.icatch.jta;import java.io.Serializable;import amingException;
    import Reference;
    import Referenceable;
    import HeuristicMixedException;
    import HeuristicRollbackException;
    import InvalidTransactionException;
    import ;
    import RollbackException;
    import SystemException;
    import Transaction;
    import TransactionManager;
    import UserTransaction;import com.atomikos.TSInitInfo;
    import com.atomikos.UserTransactionService;
    import com.atomikos.UserTransactionServiceImp;
    import com.atomikos.util.SerializableObjectFactory;/*** * * * * * A straightforward, zero-setup implementation of a transaction manager. J2SE* applicati can use an instance of this class to get a handle to the* transaction manager, and automatically startup or recover the transaction* service on first use. <b>J2EE applicati should OT use this class in order* to avoid the concurrent use of different transaction services. For J2EE* applicati, we have the class J2eeTransactionManager instead.</b>*/
    public class UserTransactionManager implements TransactionManager,Serializable, Referenceable, UserTransaction
    {private static final long serialVersionUID = -65578908710288096L;private transient TransactionManagerImp tm;private UserTransactionService uts;private boolean forceShutdown;private boolean startupTransactionService;private boolean closed;private void checkSetup () throws SystemException{if ( closed ) throw new SystemException ( This UserTransactionManager instance was closed already. Call init() to reuse if desired. );synchronized (  ) {tm = (TransactionManagerImp) TransactionManagerImp.getTransactionManager ();if ( tm == null ) {// not initialized -> startup TM// println ( STARTIG UP TM!!!!!!);if ( getStartupTransactionService() ) {uts = new UserTransactionServiceImp ();TSInitInfo info =  ();uts.init ( info );tm = (TransactionManagerImp) TransactionManagerImp.getTransactionManager ();}else {throw new SystemException ( Transaction service not running );}}}}public UserTransactionManager(){//startup by default, to have backward compatibilitythis.startupTransactionService = true; = false;}/*** Sets whether the transaction service should be * started if not already running. * @param startup*/public void setStartupTransactionService ( boolean startup ){this.startupTransactionService = startup;}/*** Returns true if the transaction service will * be started if not already running.* @return*/public boolean getStartupTransactionService(){return this.startupTransactionService;}/*** Performs initialization if necessary.* This will startup the TM (if not running)* and perform recovery, unless <b>getStartupTransactionService</b>* returns false.* * @throws SystemException*/public void init() throws SystemException{closed = false;checkSetup();}/*** @see TransactionManager#begin()*/public void begin () throws otSupportedException, SystemException{checkSetup ();tm.begin ();}public boolean getForceShutdown(){return forceShutdown;}/*** Sets the force shutdown mode to use during close.* @param value */public void setForceShutdown ( boolean value ){this.forceShutdown = value;}/*** @see TransactionManager#commit()*/public void commit () throws RollbackException, HeuristicMixedException,HeuristicRollbackException, SecurityException,IllegalStateException, SystemException{checkSetup ();tmmit ();}/*** @see TransactionManager#getStatus()*/public int getStatus () throws SystemException{checkSetup ();return tm.getStatus ();}/*** @see TransactionManager#getTransaction()*/public Transaction getTransaction () throws SystemException{checkSetup ();return tm.getTransaction ();}/*** @see TransactionManager#resume(Transaction)*/public void resume ( Transaction tx ) throws InvalidTransactionException,IllegalStateException, SystemException{checkSetup ();tm.resume ( tx );}/*** @see TransactionManager#rollback()*/public void rollback () throws IllegalStateException, SecurityException,SystemException{checkSetup ();tm.rollback ();}/*** @see TransactionManager#setRollbackOnly()*/public void setRollbackOnly () throws IllegalStateException,SystemException{checkSetup ();tm.setRollbackOnly ();}/*** @see TransactionManager#setTransactionTimeout(int)*/public void setTransactionTimeout ( int secs ) throws SystemException{checkSetup ();tm.setTransactionTimeout ( secs );}/*** @see TransactionManager#suspend()*/public Transaction suspend () throws SystemException{checkSetup ();return tm.suspend ();}/*** @see Referenceable#getReference()*/public Reference getReference () throws amingException{return  ( this );}/*** Closes the transaction service, but only if it was * implicitly started via this instance.* In other words, if the transaction service was started* in another way then this method will not do anything.**/public void close(){if ( uts != null ) {uts.shutdown ( forceShutdown );uts = null;}closed = true;}}

     

  4. 对于JDBC,使用我们的一个实例com.atomikos.jdbc.AtomikosDataSourceBean或者,对于non-XA驱动,可以使用com.atomikos.AtomikosonXADataSourceBean
    /*** Copyright (C) 2000-2010 Atomikos <info@atomikos>** This code (Atomikos TransactiEssentials), by itself,* is being distributed under the* Apache License, Version 2.0 (License), a copy of which may be found at* . .* You may not use this file except in compliance with the License.** While the License grants certain patent license rights,* those patent license rights only extend to the use of* Atomikos TransactiEssentials by itself.** This code (Atomikos TransactiEssentials) contains certain interfaces* in package (namespace) com.atomikos.icatch* (including com.atomikos.icatch.Participant) which, if implemented, may* infringe one or more patents held by Atomikos.* It should be appreciated that you may OT implement such interfaces;* licensing to implement these interfaces must be obtained separately from Atomikos.** Unless required by applicable law or agreed to in writing, software* distributed under the License is distributed on an AS IS BASIS,* WITHOUT WARRATIES OR CODITIOS OF AY KID, either express or implied.*/package com.atomikos.jdbc;
    import java.util.Enumeration;
    import java.util.Properties;import javax.sql.XADataSource;import com.atomikos.beans.PropertyUtils;
    import com.atomikos.datasource.RecoverableResource;
    import com.atomikos.datasource.xa.jdbc.JdbcTransactionalResource;
    import com.atomikos.icatch.system.Configuration;
    import com.atomikos.jdbc.AbstractDataSourceBean;
    import com.atomikos.util.ClassLoadingHelper;/*** The preferred class for using Atomikos connection pooling. Use an instance of* this class if you want to use Atomikos JTA-enabled connection pooling. All* you need to do is ctruct an instance and set the required properties as* outlined below. The resulting bean will automatically register with the* transaction service (for recovery) and take part in active transacti.* All SQL done over connecti (gotten from this class) will participate in JTA transacti.*/public class AtomikosDataSourceBean 
    extends AbstractDataSourceBean
    {private static final long serialVersionUID = 1L;private Properties xaProperties = null;private String xaDataSourceClassame;private transient XADataSource xaDataSource;public AtomikosDataSourceBean() {this.xaProperties = new Properties();}protected String printXaProperties(){StringBuffer ret = new StringBuffer();if ( xaProperties != null ) {Enumeration it = xaProperties.propertyames();ret.append ( [ );boolean first = true;while ( it.hasMoreElements() ) {if ( ! first ) ret.append ( , );String name = ( String ) ();String value = xaProperties.getProperty( name);ret.append ( name ); ret.append ( = ); ret.append ( value );first = false;}ret.append ( ] );}return ();}/*** Gets the properties used to* configure the XADataSource.  */public Properties getXaProperties(){return xaProperties;}/*** Sets the properties (name,value pairs) used to* configure the XADataSource. Required, unless you call setXaDataSource directly.* * @param xaProperties * **/public void setXaProperties ( Properties xaProperties ) {this.xaProperties = xaProperties;}/*** Get the XADataSource class name.*/public String getXaDataSourceClassame() {return xaDataSourceClassame;}/*** Sets the fully qualified underlying XADataSource class name. Required, unless you * call setXaDataSource directly.* * @param xaDataSourceClassame*/public void setXaDataSourceClassame ( String xaDataSourceClassame ) {this.xaDataSourceClassame = xaDataSourceClassame;}/*** Gets the configured XADataSource (if any).* @return The instance, or null if none.*/public XADataSource getXaDataSource(){return xaDataSource;}/*** Sets the XADataSource directly - instead of providing the xaDataSourceClassame and xaProperties.* @param xaDataSource*/public void setXaDataSource(XADataSource xaDataSource){this.xaDataSource = xaDataSource;}protected com.atomikos.datasource.pool.ConnectionFactory doInit() throws Exception {if (xaDataSource == null){if (xaDataSourceClassame == null)throwAtomikosSQLException(Property 	xaDataSourceClassame	 cannot be null);if (xaProperties == null)throwAtomikosSQLException(Property 	xaProperties	 cannot be null);}if ( Configuration.isInfoLoggingEnabled() ) Configuration.logInfo(this  : initializing with [  xaDataSourceClassame=  xaDataSourceClassame  ,  uniqueResourceame=  getUniqueResourceame()  ,  maxPoolSize=  getMaxPoolSize()  ,  minPoolSize=  getMinPoolSize()  ,  borrowConnectionTimeout=  getBorrowConnectionTimeout()  ,  maxIdleTime=  getMaxIdleTime()  ,  reapTimeout=  getReapTimeout()  ,  maintenanceInterval=  getMaintenanceInterval()  ,  testQuery=  getTestQuery()  ,  xaProperties=  printXaProperties()   loginTimeout=  getLoginTimeout() ]);if (xaDataSource == null){Class xadsClass = null;try {xadsClass = ClassLoadingHelper.loadClass ( getXaDataSourceClassame() );} catch ( ClassotFoundException nf ) { ( The class 	  getXaDataSourceClassame() 	 specified by property 	xaDataSourceClassame	 could not be found in the classpath. Please make sure the spelling is correct, and that the required jar(s) are in the classpath. , nf );}Object driver =  ();if ( ! ( driver instanceof XADataSource ) ) { (The class 	  getXaDataSourceClassame() 	 specified by property 	xaDataSourceClassame	 does not implement the required interface javax.jdbc.XADataSource. Please make sure the spelling is correct, and check your JDBC driver vendor	s documentation. );}xaDataSource = (XADataSource) driver;xaDataSource.setLoginTimeout ( getLoginTimeout() );xaDataSource.setLogWriter ( getLogWriter() );PropertyUtils.setProperties(xaDataSource, xaProperties );}JdbcTransactionalResource tr = new JdbcTransactionalResource(getUniqueResourceame() , xaDataSource);com.atomikos.datasource.pool.ConnectionFactory cf = new com.atomikos.jdbc.AtomikosXAConnectionFactory(xaDataSource, tr, this);Configuration.addResource ( tr );return cf;}protected void doClose() {RecoverableResource res = Configuration.getResource ( getUniqueResourceame() );if ( res != null ) {Configuration.removeResource ( getUniqueResourceame() );//fix for case 26005
                ();}}    public String toString() {String ret = AtomikosDataSoureBean;String name = getUniqueResourceame();if ( name != null ) {ret = ret   	  name  	;}return ret;}}
    /*** Copyright (C) 2000-2010 Atomikos <info@atomikos>** This code (Atomikos TransactiEssentials), by itself,* is being distributed under the* Apache License, Version 2.0 (License), a copy of which may be found at* . .* You may not use this file except in compliance with the License.** While the License grants certain patent license rights,* those patent license rights only extend to the use of* Atomikos TransactiEssentials by itself.** This code (Atomikos TransactiEssentials) contains certain interfaces* in package (namespace) com.atomikos.icatch* (including com.atomikos.icatch.Participant) which, if implemented, may* infringe one or more patents held by Atomikos.* It should be appreciated that you may OT implement such interfaces;* licensing to implement these interfaces must be obtained separately from Atomikos.** Unless required by applicable law or agreed to in writing, software* distributed under the License is distributed on an AS IS BASIS,* WITHOUT WARRATIES OR CODITIOS OF AY KID, either express or implied.*/package com.atomikos.;import java.sql.Connection;
    import java.sql.SQLException;import com.atomikos.datasource.pool.ConnectionFactory;
    import com.atomikos.icatch.HeuristicMessage;
    import com.atomikos.icatch.system.Configuration;
    import com.atomikos.jdbc.AbstractDataSourceBean;
    import com.atomikos.util.DynamicProxy;/*** * A Bean class for DataSource access to non-XA JDBC implementati. * Instances are JTA transaction-aware and can rollback the work done * over multiple connecti (provided that all work was done in one and the same thread).* **/
    public class AtomikosonXADataSourceBean extends AbstractDataSourceBean 
    {private static final long serialVersionUID = 1L;private String url;private String user;private String password;private String driverClassame;private boolean readOnly;/*** Sets the URL to use for getting connecti. Required.* * @param url*/public void setUrl ( String url ) {this.url = url;}/*** Gets the URL to connect. */public String getUrl(){return url;}/*** Marks this datasource as being used for read-only work. Optional.* * Setting this to true will avoid warnings/errors upon recovery. ReadOnly mode* is intended to avoid XA configuration of databases where no updates are* being done.* * @param readOnly Defaults to false.*/public void setReadOnly ( boolean readOnly ) {this.readOnly = readOnly;}/*** @return Whether or not this datasource is marked as readOnly.*/public boolean getReadOnly(){return readOnly;}/*** @return The password.*/public String getPassword (){return password;}/*** Sets the password to use.* * @param string*/public void setPassword ( String string ){password = string;}/*** Set the user name to get connecti with.* * @param string*/public void setUser ( String string ){user = string;}/*** @return The URL to connect with.*/public String getUser (){return user;}/*** * @return The DriverManager class name.*/public String getDriverClassame (){return driverClassame;}/*** Sets the driver class name to be used by the DriverManager. Required.* * @param string*/public void setDriverClassame ( String string ){driverClassame = string;}protected void doClose() {//nothing to do
        }protected ConnectionFactory doInit() throws Exception {AtomikosonXAConnectionFactory ret = null;if ( Configuration.isInfoLoggingEnabled() ) Configuration.logInfo(this  : initializing with [  uniqueResourceame=  getUniqueResourceame()  ,  maxPoolSize=  getMaxPoolSize()  ,  minPoolSize=  getMinPoolSize()  ,  borrowConnectionTimeout=  getBorrowConnectionTimeout()  ,  maxIdleTime=  getMaxIdleTime()  ,  reapTimeout=  getReapTimeout()  ,  maintenanceInterval=  getMaintenanceInterval()  ,  testQuery=  getTestQuery()  ,  driverClassame=  getDriverClassame()  ,  user=  getUser()  ,  url=  getUrl()   loginTimeout=  getLoginTimeout() ]);ret = new com.atomikos.AtomikosonXAConnectionFactory ( this , url , driverClassame , user , password , getLoginTimeout() , readOnly ) ;ret.init();return ret;}public synchronized Connection getConnection ( HeuristicMessage hmsg ) throws SQLException{if ( Configuration.isInfoLoggingEnabled() ) Configuration.logInfo ( this  : getConnection (   hmsg   )... );init();//let pool take care of reusing an existing handleConnection proxy = super.getConnection ( hmsg );          // here we are certain that proxy is not null -> increase the use countDynamicProxy dproxy = ( DynamicProxy ) proxy;com.atomikos.AtomikosThreadLocalConnection previous = (AtomikosThreadLocalConnection) dproxy.getInvocationHandler();previous.incUseCount();previous.addHeuristicMessage ( hmsg );if ( Configuration.isDebugLoggingEnabled() ) Configuration.logDebug ( this  : returning   proxy );return proxy;}public String toString() {String ret = AtomikosonXADataSourceBean;String name = getUniqueResourceame();if ( name != null ) {ret = ret   	  name  	;}return ret;}}

     

  5. 对于JMS,可以使用我们的实例com.atomikos.jms.AtomikosConnectionFactoryBean, com.atomikos.AbstractJmsSenderTemplate(发送信息时使用)com.atomikos.MessageDrivenContainer(接收时使用)
    /*** Copyright (C) 2000-2010 Atomikos <info@atomikos>** This code (Atomikos TransactiEssentials), by itself,* is being distributed under the* Apache License, Version 2.0 (License), a copy of which may be found at* . .* You may not use this file except in compliance with the License.** While the License grants certain patent license rights,* those patent license rights only extend to the use of* Atomikos TransactiEssentials by itself.** This code (Atomikos TransactiEssentials) contains certain interfaces* in package (namespace) com.atomikos.icatch* (including com.atomikos.icatch.Participant) which, if implemented, may* infringe one or more patents held by Atomikos.* It should be appreciated that you may OT implement such interfaces;* licensing to implement these interfaces must be obtained separately from Atomikos.** Unless required by applicable law or agreed to in writing, software* distributed under the License is distributed on an AS IS BASIS,* WITHOUT WARRATIES OR CODITIOS OF AY KID, either express or implied.*/package com.atomikos.jms;import java.io.Serializable;import javax.jms.ConnectionFactory;
    import javax.jms.JMSException;
    import amingException;
    import Reference;
    import Referenceable;import com.atomikos.util.SerializableObjectFactory;/*** * * Common logic for the connection factory beans.**/public abstract class AbstractConnectionFactoryBean 
    implements Serializable, Referenceable, ConnectionFactory
    {protected String resourceame_;protected String xaFactoryJndiame_;protected AbstractConnectionFactoryBean ( ){this.xaFactoryJndiame_ = ;this.resourceame_ = someUniqueame;}/*** Sets the JDI name of the underlying XAConnectionFactory (optional). This is* optional and an alternative to directly supplying the required factory* through setXaConnectionFactory().* * @param name*            The JDI name where the XAConnectionFactory can be found.*            It is up to the client to make sure that the name exists and*            points to an existing XAConnectionFactory.*/public void setXaFactoryJndiame ( String name ) {xaFactoryJndiame_ = name;}/*** Retrieve the JDI name where the XAConnectionFactory is expected.* * @return String the name or an empty String if not set.*/public String getXaFactoryJndiame() {return xaFactoryJndiame_;}/*** Set the unique resource name for this factory (required). A unique* resource name is needed by the transaction service in order to register* and recover the underlying XA transacti. * ote: the value you set here should not exceed 45 bytes in length.* * <p><b>MQSeries OTE:</b> For* IBM MQSeries, the name should include MQSeries_XA_RMI or the XA routines* will not work properly! * * @param name*            The unique resource name.*/public void setResourceame ( String name ) {resourceame_ = name;}/*** Get the resource name.* * @return String the unique resource name as previously set.*/public String getResourceame() {return resourceame_;}public Reference getReference() throws amingException {return  ( this );}/*** Initialization method to register the underlying resource for recovery* and other init code. * * @throws JMSException*/public void init() throws JMSException{checkSetup();}protected abstract void checkSetup() throws JMSException;}
    /*** Copyright (C) 2000-2010 Atomikos <info@atomikos>** This code (Atomikos TransactiEssentials), by itself,* is being distributed under the* Apache License, Version 2.0 (License), a copy of which may be found at* . .* You may not use this file except in compliance with the License.** While the License grants certain patent license rights,* those patent license rights only extend to the use of* Atomikos TransactiEssentials by itself.** This code (Atomikos TransactiEssentials) contains certain interfaces* in package (namespace) com.atomikos.icatch* (including com.atomikos.icatch.Participant) which, if implemented, may* infringe one or more patents held by Atomikos.* It should be appreciated that you may OT implement such interfaces;* licensing to implement these interfaces must be obtained separately from Atomikos.** Unless required by applicable law or agreed to in writing, software* distributed under the License is distributed on an AS IS BASIS,* WITHOUT WARRATIES OR CODITIOS OF AY KID, either express or implied.*/package com.atomikos.;import java.io.Serializable;
    import java.util.Map;import javax.jms.Connection;
    import javax.jms.Destination;
    import javax.jms.JMSException;
    import javax.jms.Queue;
    import javax.jms.Session;
    import javax.jms.Topic;
    import Status;
    import SystemException;import com.atomikos.icatch.jta.UserTransactionManager;
    import com.atomikos.icatch.system.Configuration;
    import com.atomikos.jms.AtomikosConnectionFactoryBean;
    import com.atomikos.jms.AtomikosJMSException;
    import com.atomikos.jms.AtomikosTransactionRequiredJMSException;/*** Common functionality for the sender templates.**/public abstract class AbstractJmsSenderTemplate 
    {protected AtomikosConnectionFactoryBean connectionFactoryBean;private String user;protected String password;protected Destination destination;private String destinationame;private Destination replyToDestination;private String replyToDestinationame;private int deliveryMode;private int priority;private long timeToLive;protected boolean inited;protected AbstractJmsSenderTemplate(){// set default values according to Sun	s JMS javadocssetTimeToLive ( 0 );setDeliveryMode ( javax.jms.DeliveryMode.PERSISTET );setPriority ( 4 );}protected abstract Session getOrRefreshSession ( Connection c ) throws JMSException;protected abstract Connection getOrReuseConnection() throws JMSException;protected abstract void afterUseWithoutErrors ( Connection c , Session s ) throws JMSException;protected void destroy ( Connection c , Session s)throws JMSException {try {if ( s != null ) ();} catch ( JMSException warn ) {Configuration.logWarning ( this  : error closing session , warn);}try {if ( c != null ) ();} catch ( JMSException warn ) {Configuration.logWarning ( this  : error closing connection , warn);}}    protected synchronized Connection refreshConnection() throws JMSException {Connection connection = null;if ( getDestinationame() == null )throw new JMSException ( Please call setDestination or setDestinationame first! );if ( user != null ) {connection =  (user, password );} else {connection =  ();}connection.start ();return connection;}/*** Initializes the session for sending. * Call this method first.*/public void init() throws JMSException{if ( ! inited ) {if ( connectionFactoryBean == null ) throw new IllegalStateException ( Property 	atomikosConnectionFactoryBean	 must be set first! );if ( getDestinationame() == null ) {throw new IllegalStateException ( Property 	destination	 or 	destinationame	 must be set first! );}StringBuffer msg = new StringBuffer();msg.append ( this  :configured with [ );msg.append ( user= ).append ( getUser() ).append ( ,  );msg.append ( password= ).append ( password ).append ( ,  );msg.append ( deliveryMode= ).append ( getDeliveryMode() ).append ( ,  );msg.append ( timeToLive= ).append ( getTimeToLive() ).append ( ,  );msg.append ( priority= ).append ( getPriority() ).append ( ,  );msg.append ( destination= ).append( getDestinationame() ).append ( ,  );msg.append ( replyToDestination= ).append ( getReplyToDestinationame() );msg.append ( ] );if ( Configuration.isDebugLoggingEnabled() ) Configuration.logDebug ( () );inited = true;        }}private void retrieveDestinationIfecessary() throws JMSException {if ( getDestination() == null ) {String dame = getDestinationame();RetrieveDestinationCallback cb = new RetrieveDestinationCallback ( dame );executeCallbackInternal ( cb );setDestination ( cb.getDestination() );}}private void retrieveReplyToDestinationIfecessary() throws JMSException {if ( getReplyToDestination() == null ) {String dame = getReplyToDestinationame();if ( dame != null ) {RetrieveDestinationCallback cb = new RetrieveDestinationCallback ( dame );executeCallbackInternal ( cb );setReplyToDestination ( cb.getDestination() );}}}/*** Sets the connection factory to use. Required.* @param connectionFactory*/public void setAtomikosConnectionFactoryBean(AtomikosConnectionFactoryBean connectionFactory) { = connectionFactory;}public AtomikosConnectionFactoryBean getAtomikosConnectionFactoryBean() {return connectionFactoryBean;}public Destination getDestination() {return destination;}/*** Sets the (provider-specific) destination name in order* to lookup the destination (rather than providing one directly).* * Required, unless you set the destination directly.* * @param destinationame*/public void setDestinationame ( String destinationame ) {this.destinationame = destinationame;}/*** Sets the destination to send to. Required, unless* you set the destinationame instead.* * @param destination*/public void setDestination(Destination destination) {this.destination = destination;}private String getame(Destination d, String destinationame ) {String ret = destinationame;if ( ret == null ) {if ( d instanceof Queue ) {Queue q = ( Queue ) d;try {ret = q.getQueueame();} catch ( JMSException e ) {if ( Configuration.isDebugLoggingEnabled() ) Configuration.logDebug ( this  : error retrieving queue name , e );}} else if ( d instanceof Topic ) {Topic t = ( Topic ) d;try {ret = t.getTopicame();} catch ( JMSException e ) {if ( Configuration.isDebugLoggingEnabled() ) Configuration.logDebug ( this  : error retrieving topic name , e );}}}return ret;}protected String getDestinationame() {return getame ( getDestination() , destinationame );}protected String getReplyToDestinationame() {return getame ( getReplyToDestination() , replyToDestinationame );}/*** @return The user to connect with, or null if no explicit authentication*         is to be used.*/public String getUser() {return user;}/*** If this session is used for sending request/reply messages, then this* property indicates the destination where the replies are to be sent (optional). The* session uses this to set the JMSReplyTo header accordingly. This property* can be omitted if no reply is needed.* * <p>* The replyToDestination should be in the same JMS vendor domain as the send* queue. To cross domains, configure a bridge for both the request and the* reply channels.*/public void setReplyToDestination(Destination destination) {this.replyToDestination = destination;}/*** Sets the provider-specific replyToDestinationame. Optional.* * @param replyToDestinationame*/public void setReplyToDestinationame ( String replyToDestinationame ) {this.replyToDestinationame = replyToDestinationame;}    /*** Gets the replyToDestination.* * @return*/public Destination getReplyToDestination() {return replyToDestination;}/*** Set the password for explicit authentication (optional). * This is only required if* the user has also been set.* * @param password*            The password.*/public void setPassword(String password) {this.password = password;}/*** Set the user to use for explicit authentication (optional). If no explicit* authentication is required then this method should not be called.* * @param user*/public void setUser(String user) {this.user = user;}protected void executeCallbackInternal ( JmsSenderTemplateCallback callback ) throws JMSException {init();Session  session = null;Connection conn = null;try {conn = getOrReuseConnection();session = getOrRefreshSession ( conn );    if ( Configuration.isDebugLoggingEnabled() ) Configuration.logDebug ( Calling callback... );callback.doInJmsSession ( session );if ( Configuration.isDebugLoggingEnabled() ) Configuration.logDebug ( Callback done! );afterUseWithoutErrors ( conn , session );} catch ( AtomikosTransactionRequiredJMSException notx ) {destroy ( conn , session );String msg = The JMS session you are using requires a JTA transaction context for the calling thread and none was found.  \n Please correct your code to do one of the following:   \n             1. start a JTA transaction before sending any message, or  \n  2. increase the maxPoolSize of the AtomikosConnectionFactoryBean to avoid transaction timeout while waiting for a connection.;Configuration.logWarning ( msg ); ( msg );} catch ( JMSException e ) {e.printStackTrace();destroy ( conn , session );String msg = this  : error in sending JMS message;( msg , e );}}/*** Executes an application-level call-back within the managed session.* * @param callback* @throws JMSException*/public void executeCallback(JmsSenderTemplateCallback callback) throws JMSException {init();        retrieveDestinationIfecessary();retrieveReplyToDestinationIfecessary();UserTransactionManager tm = new UserTransactionManager ();try {if ( tm.getStatus () != Status.STATUS_ACTIVE )throw new JMSException (This method requires an active transaction! );} catch ( SystemException e ) {Configuration.logWarning ( this : error in getting transaction status, e );throw new RuntimeException ( e.getMessage () );}executeCallbackInternal ( callback );}/*** @return The deliverymode for messages sent in this session.*/public int getDeliveryMode() {return deliveryMode;}/*** @return The priority for messages sent in this session.*/public int getPriority() {return priority;}/*** @return The timeToLive for messages sent in this session.*/public long getTimeToLive() {return timeToLive;}/*** * Set the deliverymode for messages sent in this session (optional). Defaults to* persistent.* * @param*/public void setDeliveryMode(int i) {deliveryMode = i;}/*** Set the priority for messages sent in this session (optional). Defaults to 4.* * @param*/public void setPriority(int i) {priority = i;}/*** Set the time to live for messages sent in this session (optional). Defaults to 0.* * @param*/public void setTimeToLive(long l) {timeToLive = l;}/*** Sends a TextMessage.* * @param content The text as a string.* @throws JMSException */public void sendTextMessage(String content) throws JMSException {retrieveDestinationIfecessary();retrieveReplyToDestinationIfecessary();SendTextMessageCallback cb = new SendTextMessageCallback ( content , getDestination() , getReplyToDestination() , getDeliveryMode() , getPriority() , getTimeToLive() );executeCallback ( cb );}/*** Sends a MapMessage.* * @param content The Map to get the content from.* * @throws JMSException*/public void sendMapMessage(Map content) throws JMSException {retrieveDestinationIfecessary();retrieveReplyToDestinationIfecessary();SendMapMessageCallback cb = new SendMapMessageCallback ( content , getDestination() , getReplyToDestination() , getDeliveryMode() , getPriority() , getTimeToLive() );executeCallback ( cb );        }/*** Sends an ObjectMessage.* * @param content The serializable object content.* @throws JMSException*/public void sendObjectMessage(Serializable content) throws JMSException {retrieveDestinationIfecessary();retrieveReplyToDestinationIfecessary();SendObjectMessageCallback cb = new SendObjectMessageCallback ( content , getDestination() , getReplyToDestination() , getDeliveryMode() , getPriority() , getTimeToLive() );executeCallback ( cb );        }/*** Sends a ByteMessage.* * @param content The content as a byte array.* @throws JMSException*/public void sendBytesMessage(byte[] content) throws JMSException {retrieveDestinationIfecessary();retrieveReplyToDestinationIfecessary();SendBytesMessageCallback cb = new SendBytesMessageCallback ( content , getDestination() , getReplyToDestination() , getDeliveryMode() , getPriority() , getTimeToLive() );executeCallback ( cb );}/*** Closes all resources.*/public void close() {try {Connection c = getOrReuseConnection();Session s = getOrRefreshSession(c);destroy(c, s);} catch (JMSException e) {Configuration.logWarning ( this  : error closing , e );}();}}
    /*** Copyright (C) 2000-2010 Atomikos <info@atomikos>** This code (Atomikos TransactiEssentials), by itself,* is being distributed under the* Apache License, Version 2.0 (License), a copy of which may be found at* . .* You may not use this file except in compliance with the License.** While the License grants certain patent license rights,* those patent license rights only extend to the use of* Atomikos TransactiEssentials by itself.** This code (Atomikos TransactiEssentials) contains certain interfaces* in package (namespace) com.atomikos.icatch* (including com.atomikos.icatch.Participant) which, if implemented, may* infringe one or more patents held by Atomikos.* It should be appreciated that you may OT implement such interfaces;* licensing to implement these interfaces must be obtained separately from Atomikos.** Unless required by applicable law or agreed to in writing, software* distributed under the License is distributed on an AS IS BASIS,* WITHOUT WARRATIES OR CODITIOS OF AY KID, either express or implied.*/package com.atomikos.;import java.util.ArrayList;
    import java.util.Iterator;
    import java.util.List;import javax.jms.Destination;
    import javax.jms.ExceptionListener;
    import javax.jms.JMSException;
    import javax.jms.MessageListener;import com.atomikos.icatch.system.Configuration;
    import com.atomikos.jms.AtomikosConnectionFactoryBean;/*** * A message-driven container for asynchronously receiving JMS messages* from a topic or queue, within a managed JTA transaction context.* * Upon start, an instance of this class will create a number of* concurrent sessi that listen for incoming messages on the same destination.* MessageListener instances should be thread-safe if the pool size is larger* than one. ote: in general, after start() any changed properties are only* effective on the next start() event.* * <p>* <b>IMPORTAT:</b> the transactional behaviour guarantees redelivery after failures.* As a side-effect, this can lead to so-called <em>poison messages</em>: messages* whose processing repeatedly fails due to some recurring error (for instance, a primary* key violation in the database, a ullPointerException, ...). Poison messages are problematic* because they can prevent other messages from being processed, and block the system.*  * To avoid poison messages, make sure that your MessageListener implementation * only throws a <b>RuntimeException</b> when the problem is <em>transient</em>. In that* case, the system will perform rollback and the message will be redelivered* facing a clean system state. All non-transient errors (, those that happen* each time a message is delivered) indicate problems at the application level* and should be dealt with by writing better application code.*/public class MessageDrivenContainer 
    implements MessageCumerSessionProperties
    {private static final int DEFAULT_TIMEOUT = 0;private AtomikosConnectionFactoryBean connectionFactoryBean;private MessageListener messageListener;private String user;private String password;private Destination destination;private String destinationame;private int transactionTimeout;private int poolSize;private List sessi;private boolean daemonThreads;private boolean notifyListenerOnClose;private String messageSelector;private ExceptionListener exceptionListener;private String subscriberame;private boolean noLocal;private boolean unsubscribeOnClose;private String clientID;private int receiveTimeout;public MessageDrivenContainer(){sessi = new ArrayList ();notifyListenerOnClose = false;setPoolSize ( 1 );setTransactionTimeout ( DEFAULT_TIMEOUT );}private MessageCumerSession createSession() {return new MessageCumerSession ( this );}/*** Sets the clientID for durable subscripti. Optional.* * @param clientID*/public void setClientID ( String clientID ) { = clientID;}/*** Sets the connection factory to use. Required.* @param bean*/public void setAtomikosConnectionFactoryBean ( AtomikosConnectionFactoryBean bean ){ = bean;}public AtomikosConnectionFactoryBean getAtomikosConnectionFactoryBean(){return connectionFactoryBean;}/*** Gets the destination. * * @return The destination, or null if not set.*/public Destination getDestination(){return destination;}/*** Sets the JMS destination to listen on (required unless the destinationame is set instead).* * @param dest*/public void setDestination ( Destination dest ){this.destination = dest;}/*** Gets the destination name.* * @return The name, or null if not set.*/public String getDestinationame(){return destinationame;}/*** Sets the JMS provider-specific destination name* (required unless the destination is set directly). * * @param destinationame*/public void setDestinationame ( String destinationame ){this.destinationame = destinationame;}/*** Sets whether threads should be daemon threads or not (optional).* Default is false.* @param value If true then threads will be daemon threads.*/public void setDaemonThreads ( boolean value ) {this.daemonThreads = value;}/*** Tests whether threads are daemon threads.* @return True if threads are deam.*/public boolean getDaemonThreads() {return daemonThreads;}/*** * Get the message listener if any.* * @return*/public MessageListener getMessageListener() {return messageListener;}/*** Get the transaction timeout.* * @return*/public int getTransactionTimeout() {return transactionTimeout;}/*** Get the user for connecting, or null if the default user should be used.* * @return*/public String getUser() {return user;}/*** Set the message listener to use (required). * The same instance will be used for each* session in the pool, meaning that instances need to be thread-safe. Only* one listener is allowed at a time. Call this method with a null argument* to unset the listener.* * @param listener*/public void setMessageListener ( MessageListener listener ) {messageListener = listener;Iterator it = sessi.iterator ();while ( it.hat () ) {MessageCumerSession s = (MessageCumerSession)  ();s.setMessageListener ( listener );}}/*** Set the password if explicit authentication is needed (optional). * You need to set this if the user is also set.* * @param string*/public void setPassword ( String string ) {password = string;}/*** Set the transaction timeout in seconds (optional).* * @param seconds*/public void setTransactionTimeout ( int seconds ) {transactionTimeout = seconds;}/*** Set the user to use for explicit authentication (optional). * Don	t set this property* if you want to use the default authentication.* * @param string*/public void setUser ( String string ) {user = string;}/*** Get the message selector (if any)* * @return The selector, or null if none.*/public String getMessageSelector() {return ;}/*** Set the message selector to use (optional).* * @param selector*/public void setMessageSelector ( String selector ) { = selector;}/*** Get the size of the pool.* * @return*/public int getPoolSize() {return poolSize;}/*** Sets the size of the session pool (optional).* Default is 1.* * @param size */public void setPoolSize ( int size ) {poolSize = size;}/*** Gets the exception listener (if any). * @return ull if no ExceptionListener was set.*/public ExceptionListener getExceptionListener() {return exceptionListener;}/*** Sets the exception listener (optional). The listener will be* notified of connection-level JMS errors.* * @param exceptionListener*/public void setExceptionListener ( ExceptionListener exceptionListener ) { = exceptionListener;}/*** Test if this instance will receive sends from the same connection.* * @return*/public boolean isoLocal() {return noLocal;}/*** Sets whether or not this topic should receive sends from the * same connection (optional). * * @param noLocal */public void setoLocal(boolean noLocal) { = noLocal;}/*** Gets the subscriber name (for durable subscribers).* @return The name, or null if not set (no durable subscriber).*/public String getSubscriberame() {return subscriberame;}/*** Sets the name to use for durable subscripti (optional).* <br>* <b>ote: this name will be appended with a suffix to ensure uniqueness* among instances in the pool. Otherwise, the JMS back-end would see * multiple instances subscribing with the same name - an error.</b>* * @param subscriberame*/public void setSubscriberame(String subscriberame) {this.subscriberame = subscriberame;}protected boolean getoLocal() {return isoLocal();}/*** Start listening for messages.* * @throws JMSException*/public void start() throws JMSException {if ( destination == null && destinationame == null )throw new JMSException (MessageDrivenContainer: destination not specified );if ( connectionFactoryBean == null )throw new JMSException (MessageDrivenContainer: factory not set );if ( messageListener == null )throw new JMSException (MessageDrivenContainer: messageListener not set );for ( int i = 0; i < poolSize; i ) {MessageCumerSession s = createSession();s.setMessageListener ( messageListener );s.setPassword ( password );s.setUser ( user );s.setDestination ( destination );s.setDestinationame ( destinationame );s.setAtomikosConnectionFactoryBean ( connectionFactoryBean );s.setDaemonThreads ( daemonThreads );s.setotifyListenerOnClose ( notifyListenerOnClose );s.setMessageSelector ( getMessageSelector () );s.setExceptionListener ( exceptionListener );s.setoLocal( noLocal );s.setSubscriberame( subscriberame );//set subscriber name with suffix to ensure unique namesif ( getSubscriberame() != null ) s.setSubscriberame ( getSubscriberame()  -  i );s.setoLocal ( getoLocal() );s.setClientID(clientID);try {s.startListening ();// println ( MessageDrivenContainer: started// session);} catch ( Exception e ) {Configuration.logWarning ( Error starting pool, e );}sessi.add ( s );}// set listener again to trigger listening
            setMessageListener ( messageListener );}/*** Stop listening for messages. If <b>notifyListenerOnClose</b> is set then* calling this method will notify the listener by calling its onMessage* method with a null argument (and also without transaction context).* * This method will wait for all active receive operati to unblock, which may take* up to <b>receiveTimeout</b> seconds per active thread.*/public void stop() {Iterator it = sessi.iterator ();while ( it.hat () ) {MessageCumerSession s = (MessageCumerSession)  ();s.stopListening ();}}/*** Getter to check whether the listener is notified on close.* * @return*/public boolean getotifyListenerOnClose() {return notifyListenerOnClose;}/*** Set whether the listener should be notified of close events on the pool* (optional). Default is false.* * @param b*            If true, then the listener will receive a null message if the*            pool is closed.*/public void setotifyListenerOnClose ( boolean b ) {notifyListenerOnClose = b;Iterator it = sessi.iterator ();while ( it.hat () ) {MessageCumerSession s = (MessageCumerSession)  ();s.setotifyListenerOnClose ( b );}}/*** Sets whether unsubscribe should be done at closing time (optional). Default is false.* * @param b If true, then unsubscribe will be done at closing time. This only applies to * durable subscribers (, cases where subscriberame is set).*/public void setUnsubscribeOnClose ( boolean b ) {this.unsubscribeOnClose = b;}/*** Getter to test if unsubscribe should be called on close.*/public boolean getUnsubscribeOnClose(){return unsubscribeOnClose;}/*** Gets the receive timeout in seconds.* * @return*/public int getReceiveTimeout() {int ret = receiveTimeout;if ( ret <=0 ) ret = getTransactionTimeout()/2;return ret;}/*** Sets the receive timeout in seconds, *  the number of seconds to wait for incoming messages in the message listener thread	s event loop.*  * This property is optional and defaults to half the transactionTimeout, but typically this should be lower * because the time required to shutdown (stop) this container will be bound by this value multiplied by * the number of threads (as indicated by <b>poolSize</b>).* * @param seconds*/public void setReceiveTimeout(int seconds) {this.receiveTimeout = seconds;    }}

     

  6. 请检查我们完整的用户指南

注意:虽然这个版本包含了特定的第三方产品,如RDBMS软件和JMS代理软件,请注意,AtomikosTransactiEssentials绝不是仅限制在这些特定的产品,除了RDBMS软件和JMS代理软件大多数的其他软件依然兼容。

J2SE实例:examples/jse这个文件夹包含带有源代码的各种各样的例子。可以执行这个脚本来运行这个程序(示例程序只有文本输出,而没有图形化界面输出)

         运行示例前最好安装Ant,然后打开命令窗口在 examples/jse 文件夹并且输入“ant”。

Linux/Unix/Mac OSX ote:在这些系统,你必须在终端输入 chmod ux *.sh 命令,否则,示例将无法运行。

解决问题:偶尔,一些示例可能不能再继续启动使用(尽管在开始阶段可以正常运行),这个通常是由于进程原因引起的(比如JMS代理后台环境),关闭这期间的所有进程便会解决这个问题,或者,重新启动计算机,也可以解决这个问题。

在Spring中使用:Atomikos TransactionEssentials可以很方便的于Spring相结合,运行您程序使用企业级的J2EE应用程序,而不需要EJB甚至EJB容器。另外,我们额外提供了一个强大的功能,JMS消息驱动添加到Spring的内置特性。

         查看examples/spring文件夹,将展示Atomikos TransactionEssentials如何配置基于Spring的应用程序。

在J2EE的web容器中使用:在您的J2EE应用程序环境中使用Atomikos TransactiEssentials最简单的方法是通过Spring作为pico-container(组件容器),如果想获取更多信息,请到Spring处查看。

Javadoc:

.7/index.html

 

#感谢您对电脑配置推荐网 - 最新i3 i5 i7组装电脑配置单推荐报价格的认可,转载请说明来源于"电脑配置推荐网 - 最新i3 i5 i7组装电脑配置单推荐报价格

本文地址:http://www.dnpztj.cn/diannao/884750.html

相关标签:无
上传时间: 2024-05-07 12:23:11
留言与评论(共有 17 条评论)
本站网友 精确制导导弹
24分钟前 发表
make sure that your MessageListener implementation * only throws a <b>RuntimeException</b> when the problem is <em>transient</em>. In that* case
本站网友 蒋丽萍
2分钟前 发表
may* infringe one or more patents held by Atomikos.* It should be appreciated that you may OT implement such interfaces;* licensing to implement these interfaces must be obtained separately from Atomikos.** Unless required by applicable law or agreed to in writing
本站网友 常平二手房出售
25分钟前 发表
destinationame );}protected String getReplyToDestinationame() {return getame ( getReplyToDestination()
本站网友 nepu
4分钟前 发表
Java消息服务是一个与具体平台无关的API,绝大多数MOM提供商都对JMS提供支持
本站网友 4大壮阳水果
30分钟前 发表
software* distributed under the License is distributed on an AS IS BASIS
本站网友 迅雷8
22分钟前 发表
either express or implied.*/package com.atomikos.;import java.sql.Connection; import java.sql.SQLException;import com.atomikos.datasource.pool.ConnectionFactory; import com.atomikos.icatch.HeuristicMessage; import com.atomikos.icatch.system.Configuration; import com.atomikos.jdbc.AbstractDataSourceBean; import com.atomikos.util.DynamicProxy;/*** * A Bean class for DataSource access to non-XA JDBC implementati. * Instances are JTA transaction-aware and can rollback the work done * over multiple connecti (provided that all work was done in one and the same thread).* **/ public class AtomikosonXADataSourceBean extends AbstractDataSourceBean {private static final long serialVersionUID = 1L;private String url;private String user;private String password;private String driverClassame;private boolean readOnly;/*** Sets the URL to use for getting connecti. Required.* * @param url*/public void setUrl ( String url ) {this.url = url;}/*** Gets the URL to connect. */public String getUrl(){return url;}/*** Marks this datasource as being used for read-only work. Optional.* * Setting this to true will avoid warnings/errors upon recovery. ReadOnly mode* is intended to avoid XA configuration of databases where no updates are* being done.* * @param readOnly Defaults to false.*/public void setReadOnly ( boolean readOnly ) {this.readOnly = readOnly;}/*** @return Whether or not this datasource is marked as readOnly.*/public boolean getReadOnly(){return readOnly;}/*** @return The password.*/public String getPassword (){return password;}/*** Sets the password to use.* * @param string*/public void setPassword ( String string ){password = string;}/*** Set the user name to get connecti with.* * @param string*/public void setUser ( String string ){user = string;}/*** @return The URL to connect with.*/public String getUser (){return user;}/*** * @return The DriverManager class name.*/public String getDriverClassame (){return driverClassame;}/*** Sets the driver class name to be used by the DriverManager. Required.* * @param string*/public void setDriverClassame ( String string ){driverClassame = string;}protected void doClose() {//nothing to do }protected ConnectionFactory doInit() throws Exception {AtomikosonXAConnectionFactory ret = null;if ( Configuration.isInfoLoggingEnabled() ) Configuration.logInfo(this  
本站网友 石门二手房
3分钟前 发表
unless* you set the destinationame instead.* * @param destination*/public void setDestination(Destination destination) {this.destination = destination;}private String getame(Destination d
本站网友 htmljs
1分钟前 发表
url
本站网友 南京大洋百货官网
25分钟前 发表
xa_commit
本站网友 重庆搜房网租房
4分钟前 发表
then this* property indicates the destination where the replies are to be sent (optional). The* session uses this to set the JMSReplyTo header accordingly. This property* can be omitted if no reply is needed.* * <p>* The replyToDestination should be in the same JMS vendor domain as the send* queue. To cross domains
本站网友 乌鸡汤怎么炖
8分钟前 发表
IllegalStateException
本站网友 衡阳保卫战
24分钟前 发表
* those patent license rights only extend to the use of* Atomikos TransactiEssentials by itself.** This code (Atomikos TransactiEssentials) contains certain interfaces* in package (namespace) com.atomikos.icatch* (including com.atomikos.icatch.Participant) which
本站网友 重庆租房子
22分钟前 发表
if implemented
本站网友 西安前列腺医院
19分钟前 发表
在Spring中使用:Atomikos TransactionEssentials可以很方便的于Spring相结合,运行您程序使用企业级的J2EE应用程序,而不需要EJB甚至EJB容器
本站网友 孕妇补充dha
21分钟前 发表
另外,我们额外提供了一个强大的功能,JMS消息驱动添加到Spring的内置特性
本站网友 天地孤影任我行
7分钟前 发表
 com.atomikos.AbstractJmsSenderTemplate(发送信息时使用)com.atomikos.MessageDrivenContainer(接收时使用) /*** Copyright (C) 2000-2010 Atomikos <info@atomikos>** This code (Atomikos TransactiEssentials)