Search in sources :

Example 1 with TransactionInProgressException

use of javax.jms.TransactionInProgressException in project activemq-artemis by apache.

the class ActiveMQRASession method commit.

/**
 * Commit
 *
 * @throws JMSException Failed to close session.
 */
@Override
public void commit() throws JMSException {
    if (cri.getType() == ActiveMQRAConnectionFactory.XA_CONNECTION || cri.getType() == ActiveMQRAConnectionFactory.XA_QUEUE_CONNECTION || cri.getType() == ActiveMQRAConnectionFactory.XA_TOPIC_CONNECTION) {
        throw new TransactionInProgressException("XA connection");
    }
    lock();
    try {
        Session session = getSessionInternal();
        if (cri.isTransacted() == false) {
            throw new IllegalStateException("Session is not transacted");
        }
        if (ActiveMQRASession.trace) {
            ActiveMQRALogger.LOGGER.trace("Commit session " + this);
        }
        session.commit();
    } finally {
        unlock();
    }
}
Also used : IllegalStateException(javax.jms.IllegalStateException) TransactionInProgressException(javax.jms.TransactionInProgressException) XAQueueSession(javax.jms.XAQueueSession) Session(javax.jms.Session) ActiveMQSession(org.apache.activemq.artemis.jms.client.ActiveMQSession) TopicSession(javax.jms.TopicSession) XATopicSession(javax.jms.XATopicSession) QueueSession(javax.jms.QueueSession)

Example 2 with TransactionInProgressException

use of javax.jms.TransactionInProgressException in project activemq-artemis by apache.

the class ActiveMQRASession method rollback.

/**
 * Rollback
 *
 * @throws JMSException Failed to close session.
 */
@Override
public void rollback() throws JMSException {
    if (cri.getType() == ActiveMQRAConnectionFactory.XA_CONNECTION || cri.getType() == ActiveMQRAConnectionFactory.XA_QUEUE_CONNECTION || cri.getType() == ActiveMQRAConnectionFactory.XA_TOPIC_CONNECTION) {
        throw new TransactionInProgressException("XA connection");
    }
    lock();
    try {
        Session session = getSessionInternal();
        if (cri.isTransacted() == false) {
            throw new IllegalStateException("Session is not transacted");
        }
        if (ActiveMQRASession.trace) {
            ActiveMQRALogger.LOGGER.trace("Rollback session " + this);
        }
        session.rollback();
    } finally {
        unlock();
    }
}
Also used : IllegalStateException(javax.jms.IllegalStateException) TransactionInProgressException(javax.jms.TransactionInProgressException) XAQueueSession(javax.jms.XAQueueSession) Session(javax.jms.Session) ActiveMQSession(org.apache.activemq.artemis.jms.client.ActiveMQSession) TopicSession(javax.jms.TopicSession) XATopicSession(javax.jms.XATopicSession) QueueSession(javax.jms.QueueSession)

Aggregations

IllegalStateException (javax.jms.IllegalStateException)2 QueueSession (javax.jms.QueueSession)2 Session (javax.jms.Session)2 TopicSession (javax.jms.TopicSession)2 TransactionInProgressException (javax.jms.TransactionInProgressException)2 XAQueueSession (javax.jms.XAQueueSession)2 XATopicSession (javax.jms.XATopicSession)2 ActiveMQSession (org.apache.activemq.artemis.jms.client.ActiveMQSession)2