Search in sources :

Example 36 with IllegalStateException

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

the class ActiveMQSession method deleteTemporaryQueue.

public void deleteTemporaryQueue(final ActiveMQDestination tempQueue) throws JMSException {
    if (!tempQueue.isTemporary()) {
        throw new InvalidDestinationException("Not a temporary queue " + tempQueue);
    }
    try {
        QueueQuery response = session.queueQuery(tempQueue.getSimpleAddress());
        if (!response.isExists()) {
            throw new InvalidDestinationException("Cannot delete temporary queue " + tempQueue.getName() + " does not exist");
        }
        if (response.getConsumerCount() > 0) {
            throw new IllegalStateException("Cannot delete temporary queue " + tempQueue.getName() + " since it has subscribers");
        }
        SimpleString address = tempQueue.getSimpleAddress();
        session.deleteQueue(address);
        connection.removeTemporaryQueue(address);
    } catch (ActiveMQException e) {
        throw JMSExceptionHelper.convertFromActiveMQException(e);
    }
}
Also used : IllegalStateException(javax.jms.IllegalStateException) ActiveMQException(org.apache.activemq.artemis.api.core.ActiveMQException) InvalidDestinationException(javax.jms.InvalidDestinationException) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) QueueQuery(org.apache.activemq.artemis.api.core.client.ClientSession.QueueQuery)

Example 37 with IllegalStateException

use of javax.jms.IllegalStateException 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)

Example 38 with IllegalStateException

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

the class ActiveMQRASession method createBrowser.

/**
 * Create a browser
 *
 * @param queue           The queue
 * @param messageSelector The message selector
 * @return The browser
 * @throws JMSException Thrown if an error occurs
 */
@Override
public QueueBrowser createBrowser(final Queue queue, final String messageSelector) throws JMSException {
    if (cri.getType() == ActiveMQRAConnectionFactory.TOPIC_CONNECTION || cri.getType() == ActiveMQRAConnectionFactory.XA_TOPIC_CONNECTION) {
        throw new IllegalStateException("Cannot create browser for javax.jms.TopicSession");
    }
    Session session = getSessionInternal();
    if (ActiveMQRASession.trace) {
        ActiveMQRALogger.LOGGER.trace("createBrowser " + session + " queue=" + queue + " selector=" + messageSelector);
    }
    QueueBrowser result = session.createBrowser(queue, messageSelector);
    if (ActiveMQRASession.trace) {
        ActiveMQRALogger.LOGGER.trace("createdBrowser " + session + " browser=" + result);
    }
    return result;
}
Also used : IllegalStateException(javax.jms.IllegalStateException) QueueBrowser(javax.jms.QueueBrowser) 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 39 with IllegalStateException

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

the class ActiveMQRASession method createBrowser.

/**
 * Create a browser
 *
 * @param queue The queue
 * @return The browser
 * @throws JMSException Thrown if an error occurs
 */
@Override
public QueueBrowser createBrowser(final Queue queue) throws JMSException {
    if (cri.getType() == ActiveMQRAConnectionFactory.TOPIC_CONNECTION || cri.getType() == ActiveMQRAConnectionFactory.XA_TOPIC_CONNECTION) {
        throw new IllegalStateException("Cannot create browser for javax.jms.TopicSession");
    }
    Session session = getSessionInternal();
    if (ActiveMQRASession.trace) {
        ActiveMQRALogger.LOGGER.trace("createBrowser " + session + " queue=" + queue);
    }
    QueueBrowser result = session.createBrowser(queue);
    if (ActiveMQRASession.trace) {
        ActiveMQRALogger.LOGGER.trace("createdBrowser " + session + " browser=" + result);
    }
    return result;
}
Also used : IllegalStateException(javax.jms.IllegalStateException) QueueBrowser(javax.jms.QueueBrowser) 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 40 with IllegalStateException

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

the class ActiveMQRASession method createTemporaryTopic.

/**
 * Create a temporary topic
 *
 * @return The temporary topic
 * @throws JMSException Thrown if an error occurs
 */
@Override
public TemporaryTopic createTemporaryTopic() throws JMSException {
    if (cri.getType() == ActiveMQRAConnectionFactory.QUEUE_CONNECTION || cri.getType() == ActiveMQRAConnectionFactory.XA_QUEUE_CONNECTION) {
        throw new IllegalStateException("Cannot create temporary topic for javax.jms.QueueSession");
    }
    lock();
    try {
        Session session = getSessionInternal();
        if (ActiveMQRASession.trace) {
            ActiveMQRALogger.LOGGER.trace("createTemporaryTopic " + session);
        }
        TemporaryTopic temp = session.createTemporaryTopic();
        if (ActiveMQRASession.trace) {
            ActiveMQRALogger.LOGGER.trace("createdTemporaryTopic " + session + " temp=" + temp);
        }
        sf.addTemporaryTopic(temp);
        return temp;
    } finally {
        unlock();
    }
}
Also used : IllegalStateException(javax.jms.IllegalStateException) 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) TemporaryTopic(javax.jms.TemporaryTopic)

Aggregations

IllegalStateException (javax.jms.IllegalStateException)44 Session (javax.jms.Session)19 Connection (javax.jms.Connection)12 QueueSession (javax.jms.QueueSession)12 Test (org.junit.Test)12 TopicSession (javax.jms.TopicSession)11 XAQueueSession (javax.jms.XAQueueSession)11 XATopicSession (javax.jms.XATopicSession)11 ActiveMQSession (org.apache.activemq.artemis.jms.client.ActiveMQSession)11 JMSException (javax.jms.JMSException)10 ActiveMQException (org.apache.activemq.artemis.api.core.ActiveMQException)8 SimpleString (org.apache.activemq.artemis.api.core.SimpleString)8 InvalidDestinationException (javax.jms.InvalidDestinationException)5 IOException (java.io.IOException)4 Queue (javax.jms.Queue)3 QueueBrowser (javax.jms.QueueBrowser)3 TopicSubscriber (javax.jms.TopicSubscriber)3 QueueQuery (org.apache.activemq.artemis.api.core.client.ClientSession.QueueQuery)3 RMQJMSException (com.rabbitmq.jms.util.RMQJMSException)2 TemporaryQueue (javax.jms.TemporaryQueue)2