1 18 19 package org.apache.activemq; 20 21 import javax.jms.JMSException ; 22 import javax.jms.QueueSession ; 23 import javax.jms.Session ; 24 import javax.jms.TopicSession ; 25 import javax.jms.TransactionInProgressException ; 26 import javax.jms.XAQueueSession ; 27 import javax.jms.XATopicSession ; 28 import javax.transaction.xa.XAResource ; 29 30 import org.apache.activemq.command.SessionId; 31 32 66 public class ActiveMQXASession extends ActiveMQSession implements QueueSession , TopicSession , XAQueueSession , XATopicSession { 67 68 public ActiveMQXASession(ActiveMQXAConnection connection, SessionId sessionId, int theAcknowlegeMode, boolean dispatchAsync) throws JMSException { 69 super(connection, sessionId, theAcknowlegeMode, dispatchAsync); 70 } 71 72 public boolean getTransacted() throws JMSException { 73 return true; 74 } 75 76 public void rollback() throws JMSException { 77 throw new TransactionInProgressException ("Cannot rollback() inside an XASession"); 78 } 79 80 public void commit() throws JMSException { 81 throw new TransactionInProgressException ("Cannot commit() inside an XASession"); 82 } 83 84 public Session getSession() throws JMSException { 85 return this; 86 } 87 88 public XAResource getXAResource() { 89 return getTransactionContext(); 90 } 91 92 public QueueSession getQueueSession() throws JMSException { 93 return new ActiveMQQueueSession(this); 94 } 95 96 public TopicSession getTopicSession() throws JMSException { 97 return new ActiveMQTopicSession(this); 98 } 99 100 107 protected void doStartTransaction() throws JMSException { 108 109 if (!getTransactionContext().isInXATransaction()) { 110 throw new JMSException ("Session's XAResource has not been enlisted in a distributed transaction."); 111 } 112 113 } 114 115 } 116 | Popular Tags |