Package org.objectweb.joram.client.jms
Class XASession
- java.lang.Object
-
- org.objectweb.joram.client.jms.XASession
-
- All Implemented Interfaces:
AutoCloseable,Runnable,Session,XASession
- Direct Known Subclasses:
XAQueueSession,XATopicSession
public class XASession extends Object implements XASession
Implements thejavax.jms.XASessioninterface.An XA session actually extends the behaviour of a normal session by providing an XA resource representing it to a Transaction Manager, so that it is part of a distributed transaction. The XASession wraps what looks like a "normal" Session object. This object takes care of producing and consuming messages, the actual sendings and acknowledgement being managed by this XA wrapper.
This class offers support to transactional environments. Client programs are strongly encouraged to use the transactional support available in their environment, rather than use these XA interfaces directly.
-
-
Field Summary
Fields Modifier and Type Field Description protected Sessionsessprivate XAResourcexaResourceThe XA resource representing the session to the transaction manager.-
Fields inherited from interface javax.jms.Session
AUTO_ACKNOWLEDGE, CLIENT_ACKNOWLEDGE, DUPS_OK_ACKNOWLEDGE, SESSION_TRANSACTED
-
-
Constructor Summary
Constructors Constructor Description XASession(Connection cnx, Session sess, XAResourceMngr rm)Constructs anXASession.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()API method.voidcommit()API method inherited from session, but intercepted here for forbidding its use in the XA context (as defined by the API).QueueBrowsercreateBrowser(Queue queue)Delegates the call to the wrapped JMS session.QueueBrowsercreateBrowser(Queue queue, String selector)Delegates the call to the wrapped JMS session.BytesMessagecreateBytesMessage()Delegates the call to the wrapped JMS session.MessageConsumercreateConsumer(Destination dest)Delegates the call to the wrapped JMS session.MessageConsumercreateConsumer(Destination dest, String selector)Delegates the call to the wrapped JMS session.MessageConsumercreateConsumer(Destination dest, String selector, boolean noLocal)Delegates the call to the wrapped JMS session.MessageConsumercreateDurableConsumer(Topic topic, String name)Delegates the call to the wrapped JMS session.MessageConsumercreateDurableConsumer(Topic topic, String name, String messageSelector, boolean noLocal)Delegates the call to the wrapped JMS session.TopicSubscribercreateDurableSubscriber(Topic topic, String name)Delegates the call to the wrapped JMS session.TopicSubscribercreateDurableSubscriber(Topic topic, String name, String selector, boolean noLocal)Delegates the call to the wrapped JMS session.MapMessagecreateMapMessage()Delegates the call to the wrapped JMS session.MessagecreateMessage()Delegates the call to the wrapped JMS session.ObjectMessagecreateObjectMessage()Delegates the call to the wrapped JMS session.ObjectMessagecreateObjectMessage(Serializable obj)Delegates the call to the wrapped JMS session.MessageProducercreateProducer(Destination dest)Delegates the call to the wrapped JMS session.QueuecreateQueue(String queueName)Delegates the call to the wrapped JMS session.MessageConsumercreateSharedConsumer(Topic topic, String sharedSubscriptionName)Delegates the call to the wrapped JMS session.MessageConsumercreateSharedConsumer(Topic topic, String sharedSubscriptionName, String messageSelector)Delegates the call to the wrapped JMS session.MessageConsumercreateSharedDurableConsumer(Topic topic, String name)Delegates the call to the wrapped JMS session.MessageConsumercreateSharedDurableConsumer(Topic topic, String name, String messageSelector)Delegates the call to the wrapped JMS session.StreamMessagecreateStreamMessage()Delegates the call to the wrapped JMS session.TemporaryQueuecreateTemporaryQueue()Delegates the call to the wrapped JMS session.TemporaryTopiccreateTemporaryTopic()Delegates the call to the wrapped JMS session.TextMessagecreateTextMessage()Delegates the call to the wrapped JMS session.TextMessagecreateTextMessage(String text)Delegates the call to the wrapped JMS session.TopiccreateTopic(String topicName)Delegates the call to the wrapped JMS session.intgetAcknowledgeMode()Delegates the call to the wrapped JMS session.SessiongetDelegateSession()MessageListenergetMessageListener()Delegates the call to the wrapped JMS session.SessiongetSession()API method.booleangetTransacted()API method.XAResourcegetXAResource()API method.voidrecover()API method inherited from session, but intercepted here for forbidding its use in the XA context (as defined by the API).voidrollback()API method inherited from session, but intercepted here for forbidding its use in the XA context (as defined by the API).voidrun()Delegates the call to the wrapped JMS session.voidsetMessageListener(MessageListener messageListener)Delegates the call to the wrapped JMS session.StringtoString()Returns a String image of this session.voidunsubscribe(String name)Delegates the call to the wrapped JMS session.
-
-
-
Field Detail
-
xaResource
private XAResource xaResource
The XA resource representing the session to the transaction manager.
-
sess
protected Session sess
-
-
Constructor Detail
-
XASession
public XASession(Connection cnx, Session sess, XAResourceMngr rm) throws JMSException
Constructs anXASession.This constructor is called by subclasses.
- Parameters:
cnx- The connection the session belongs to.sess- The wrapped "regular" session.rm- The resource manager.- Throws:
JMSException- Actually never thrown.
-
-
Method Detail
-
getDelegateSession
public final Session getDelegateSession()
-
toString
public String toString()
Returns a String image of this session.
-
getSession
public Session getSession() throws JMSException
API method. Gets the session associated with this XASession.- Specified by:
getSessionin interfaceXASession- Returns:
- the session object.
- Throws:
IllegalStateException- If the session is closed.JMSException
-
getXAResource
public XAResource getXAResource()
API method. Returns an XA resource to the caller.- Specified by:
getXAResourcein interfaceXASession- Returns:
- an XA resource.
-
getTransacted
public boolean getTransacted() throws JMSExceptionAPI method. Indicates whether the session is in transacted mode.- Specified by:
getTransactedin interfaceSession- Specified by:
getTransactedin interfaceXASession- Returns:
- true
- Throws:
IllegalStateException- If the session is closed.JMSException
-
createBrowser
public QueueBrowser createBrowser(Queue queue, String selector) throws JMSException
Delegates the call to the wrapped JMS session.- Specified by:
createBrowserin interfaceSession- Throws:
JMSException
-
createBrowser
public QueueBrowser createBrowser(Queue queue) throws JMSException
Delegates the call to the wrapped JMS session.- Specified by:
createBrowserin interfaceSession- Throws:
JMSException
-
createProducer
public MessageProducer createProducer(Destination dest) throws JMSException
Delegates the call to the wrapped JMS session.- Specified by:
createProducerin interfaceSession- Throws:
JMSException
-
createConsumer
public MessageConsumer createConsumer(Destination dest, String selector, boolean noLocal) throws JMSException
Delegates the call to the wrapped JMS session.- Specified by:
createConsumerin interfaceSession- Throws:
JMSException
-
createConsumer
public MessageConsumer createConsumer(Destination dest, String selector) throws JMSException
Delegates the call to the wrapped JMS session.- Specified by:
createConsumerin interfaceSession- Throws:
JMSException
-
createConsumer
public MessageConsumer createConsumer(Destination dest) throws JMSException
Delegates the call to the wrapped JMS session.- Specified by:
createConsumerin interfaceSession- Throws:
JMSException
-
createDurableSubscriber
public TopicSubscriber createDurableSubscriber(Topic topic, String name, String selector, boolean noLocal) throws JMSException
Delegates the call to the wrapped JMS session.- Specified by:
createDurableSubscriberin interfaceSession- Throws:
JMSException
-
createDurableSubscriber
public TopicSubscriber createDurableSubscriber(Topic topic, String name) throws JMSException
Delegates the call to the wrapped JMS session.- Specified by:
createDurableSubscriberin interfaceSession- Throws:
JMSException
-
commit
public void commit() throws JMSExceptionAPI method inherited from session, but intercepted here for forbidding its use in the XA context (as defined by the API).- Specified by:
commitin interfaceSession- Specified by:
commitin interfaceXASession- Throws:
IllegalStateException- Systematically thrown.JMSException
-
rollback
public void rollback() throws JMSExceptionAPI method inherited from session, but intercepted here for forbidding its use in the XA context (as defined by the API).- Specified by:
rollbackin interfaceSession- Specified by:
rollbackin interfaceXASession- Throws:
IllegalStateException- Systematically thrown.JMSException
-
recover
public void recover() throws JMSExceptionAPI method inherited from session, but intercepted here for forbidding its use in the XA context (as defined by the API).- Specified by:
recoverin interfaceSession- Throws:
IllegalStateException- Systematically thrown.JMSException
-
close
public void close() throws JMSExceptionAPI method. Closes the session.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceSession- Throws:
JMSException- Actually never thrown.- See Also:
Session.close
-
run
public void run()
Delegates the call to the wrapped JMS session.
-
unsubscribe
public void unsubscribe(String name) throws JMSException
Delegates the call to the wrapped JMS session.- Specified by:
unsubscribein interfaceSession- Throws:
JMSException
-
createTemporaryQueue
public TemporaryQueue createTemporaryQueue() throws JMSException
Delegates the call to the wrapped JMS session.- Specified by:
createTemporaryQueuein interfaceSession- Throws:
JMSException
-
createTemporaryTopic
public TemporaryTopic createTemporaryTopic() throws JMSException
Delegates the call to the wrapped JMS session.- Specified by:
createTemporaryTopicin interfaceSession- Throws:
JMSException
-
createTopic
public Topic createTopic(String topicName) throws JMSException
Delegates the call to the wrapped JMS session.- Specified by:
createTopicin interfaceSession- Throws:
JMSException
-
createQueue
public Queue createQueue(String queueName) throws JMSException
Delegates the call to the wrapped JMS session.- Specified by:
createQueuein interfaceSession- Throws:
JMSException
-
setMessageListener
public void setMessageListener(MessageListener messageListener) throws JMSException
Delegates the call to the wrapped JMS session.- Specified by:
setMessageListenerin interfaceSession- Throws:
JMSException
-
getMessageListener
public MessageListener getMessageListener() throws JMSException
Delegates the call to the wrapped JMS session.- Specified by:
getMessageListenerin interfaceSession- Throws:
JMSException
-
getAcknowledgeMode
public int getAcknowledgeMode() throws JMSExceptionDelegates the call to the wrapped JMS session.- Specified by:
getAcknowledgeModein interfaceSession- Throws:
JMSException
-
createTextMessage
public TextMessage createTextMessage() throws JMSException
Delegates the call to the wrapped JMS session.- Specified by:
createTextMessagein interfaceSession- Throws:
JMSException
-
createTextMessage
public TextMessage createTextMessage(String text) throws JMSException
Delegates the call to the wrapped JMS session.- Specified by:
createTextMessagein interfaceSession- Throws:
JMSException
-
createStreamMessage
public StreamMessage createStreamMessage() throws JMSException
Delegates the call to the wrapped JMS session.- Specified by:
createStreamMessagein interfaceSession- Throws:
JMSException
-
createObjectMessage
public ObjectMessage createObjectMessage() throws JMSException
Delegates the call to the wrapped JMS session.- Specified by:
createObjectMessagein interfaceSession- Throws:
JMSException
-
createObjectMessage
public ObjectMessage createObjectMessage(Serializable obj) throws JMSException
Delegates the call to the wrapped JMS session.- Specified by:
createObjectMessagein interfaceSession- Throws:
JMSException
-
createMessage
public Message createMessage() throws JMSException
Delegates the call to the wrapped JMS session.- Specified by:
createMessagein interfaceSession- Throws:
JMSException
-
createMapMessage
public MapMessage createMapMessage() throws JMSException
Delegates the call to the wrapped JMS session.- Specified by:
createMapMessagein interfaceSession- Throws:
JMSException
-
createBytesMessage
public BytesMessage createBytesMessage() throws JMSException
Delegates the call to the wrapped JMS session.- Specified by:
createBytesMessagein interfaceSession- Throws:
JMSException
-
createSharedConsumer
public MessageConsumer createSharedConsumer(Topic topic, String sharedSubscriptionName) throws JMSException
Delegates the call to the wrapped JMS session.- Specified by:
createSharedConsumerin interfaceSession- Throws:
JMSException
-
createSharedConsumer
public MessageConsumer createSharedConsumer(Topic topic, String sharedSubscriptionName, String messageSelector) throws JMSException
Delegates the call to the wrapped JMS session.- Specified by:
createSharedConsumerin interfaceSession- Throws:
JMSException
-
createDurableConsumer
public MessageConsumer createDurableConsumer(Topic topic, String name) throws JMSException
Delegates the call to the wrapped JMS session.- Specified by:
createDurableConsumerin interfaceSession- Throws:
JMSException
-
createDurableConsumer
public MessageConsumer createDurableConsumer(Topic topic, String name, String messageSelector, boolean noLocal) throws JMSException
Delegates the call to the wrapped JMS session.- Specified by:
createDurableConsumerin interfaceSession- Throws:
JMSException
-
createSharedDurableConsumer
public MessageConsumer createSharedDurableConsumer(Topic topic, String name) throws JMSException
Delegates the call to the wrapped JMS session.- Specified by:
createSharedDurableConsumerin interfaceSession- Throws:
JMSException
-
createSharedDurableConsumer
public MessageConsumer createSharedDurableConsumer(Topic topic, String name, String messageSelector) throws JMSException
Delegates the call to the wrapped JMS session.- Specified by:
createSharedDurableConsumerin interfaceSession- Throws:
JMSException
-
-