com.atomikos.jms
Class QueueConnectionFactoryBean

java.lang.Object
  extended by com.atomikos.jms.AbstractConnectionFactoryBean
      extended by com.atomikos.jms.QueueConnectionFactoryBean
All Implemented Interfaces:
Externalizable, Serializable, javax.jms.ConnectionFactory, javax.jms.QueueConnectionFactory, Referenceable

public class QueueConnectionFactoryBean
extends AbstractConnectionFactoryBean
implements javax.jms.QueueConnectionFactory, Externalizable

Use this class to access JMS queues within your JTA transactions: rollback of the transaction will also cancel any messages sent or received. Instances of this class need a JMS vendor-specific instance of XAQueueConnectionFactory to work with. Check your JMS-vendor's documentation on how to do that. Instances can be set up in a GUI wizard tool and saved on disk or in JNDI. No explicit registration with the transaction engine is necessary: this class does everything automatically. As soon as an instance is created, it is fully capable of interacting with the Atomikos transaction manager, and will transparently take part in active transactions.

Note: for transactional message receival, we highly recommend that you use the Atomikos QueueReceiverSession class. This is because the JMS specification is rather ambiguous with respect to receiving messages in a (JTA) transaction. Many J2EE application servers solve this by offering message-driven bean support, but our QueueReceiverSession allows you to do the same with 'ordinary' MessageListener implementations.

Also note: any property changes made AFTER getting the first connection will NOT have any effect!

See Also:
Serialized Form

Field Summary
 
Fields inherited from class com.atomikos.jms.AbstractConnectionFactoryBean
resourceName_, xaFactoryJndiName_
 
Constructor Summary
QueueConnectionFactoryBean()
           
 
Method Summary
protected  void checkSetup()
           
 javax.jms.Connection createConnection()
          Creates a default connection.
 javax.jms.Connection createConnection(String userName, String password)
          Creates a connection for a given user and password.
 javax.jms.QueueConnection createQueueConnection()
           
 javax.jms.QueueConnection createQueueConnection(String user, String pw)
          Creates a connection for a given user and password.
 javax.jms.XAQueueConnectionFactory getXaQueueConnectionFactory()
          Get the XAQueueConnectionFactory as previously set.
 void readExternal(ObjectInput objectInput)
           
 void setXaQueueConnectionFactory(javax.jms.XAQueueConnectionFactory xaFactory)
          Set the XAQueueConnectionFactory to use.
 void writeExternal(ObjectOutput objectOutput)
           
 
Methods inherited from class com.atomikos.jms.AbstractConnectionFactoryBean
getReference, getResourceName, getXaFactoryJndiName, init, setResourceName, setXaFactoryJndiName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

QueueConnectionFactoryBean

public QueueConnectionFactoryBean()
Method Detail

checkSetup

protected void checkSetup()
                   throws javax.jms.JMSException
Specified by:
checkSetup in class AbstractConnectionFactoryBean
Throws:
javax.jms.JMSException

getXaQueueConnectionFactory

public javax.jms.XAQueueConnectionFactory getXaQueueConnectionFactory()
Get the XAQueueConnectionFactory as previously set.

Returns:
XAQueueConnectionFactory The factory, or null if only the JNDI name was set.

setXaQueueConnectionFactory

public void setXaQueueConnectionFactory(javax.jms.XAQueueConnectionFactory xaFactory)
Set the XAQueueConnectionFactory to use. This method is optional and an alternative to setXaFactoryJndiName.

Parameters:
xaFactory - The object to use.

createQueueConnection

public javax.jms.QueueConnection createQueueConnection()
                                                throws javax.jms.JMSException
Specified by:
createQueueConnection in interface javax.jms.QueueConnectionFactory
Throws:
javax.jms.JMSException

createQueueConnection

public javax.jms.QueueConnection createQueueConnection(String user,
                                                       String pw)
                                                throws javax.jms.JMSException
Creates a connection for a given user and password.

Specified by:
createQueueConnection in interface javax.jms.QueueConnectionFactory
Parameters:
user - The user name.
pw - The password.
Returns:
QueueConnection The connection.
Throws:
javax.jms.JMSException

createConnection

public javax.jms.Connection createConnection()
                                      throws javax.jms.JMSException
Creates a default connection.

Specified by:
createConnection in interface javax.jms.ConnectionFactory
Returns:
Connection The connection.
Throws:
javax.jms.JMSException

createConnection

public javax.jms.Connection createConnection(String userName,
                                             String password)
                                      throws javax.jms.JMSException
Creates a connection for a given user and password.

Specified by:
createConnection in interface javax.jms.ConnectionFactory
Parameters:
userName - The user name.
password - The password.
Returns:
Connection The connection.
Throws:
javax.jms.JMSException

writeExternal

public void writeExternal(ObjectOutput objectOutput)
                   throws IOException
Specified by:
writeExternal in interface Externalizable
Throws:
IOException

readExternal

public void readExternal(ObjectInput objectInput)
                  throws IOException,
                         ClassNotFoundException
Specified by:
readExternal in interface Externalizable
Throws:
IOException
ClassNotFoundException


Copyright © 2011. All Rights Reserved.