Search in sources :

Example 1 with IllegalStateException

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

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

the class ActiveMQRASession method createTopic.

/**
 * Create a topic
 *
 * @param topicName The topic name
 * @return The topic
 * @throws JMSException Thrown if an error occurs
 */
@Override
public Topic createTopic(final String topicName) throws JMSException {
    if (cri.getType() == ActiveMQRAConnectionFactory.QUEUE_CONNECTION || cri.getType() == ActiveMQRAConnectionFactory.XA_QUEUE_CONNECTION) {
        throw new IllegalStateException("Cannot create topic for javax.jms.QueueSession");
    }
    Session session = getSessionInternal();
    if (ActiveMQRASession.trace) {
        ActiveMQRALogger.LOGGER.trace("createTopic " + session + " topicName=" + topicName);
    }
    Topic result = session.createTopic(topicName);
    if (ActiveMQRASession.trace) {
        ActiveMQRALogger.LOGGER.trace("createdTopic " + session + " topic=" + result);
    }
    return result;
}
Also used : IllegalStateException(javax.jms.IllegalStateException) TemporaryTopic(javax.jms.TemporaryTopic) Topic(javax.jms.Topic) 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 3 with IllegalStateException

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

the class ActiveMQRASession method createDurableSubscriber.

/**
 * Create a durable topic subscriber
 *
 * @param topic The topic
 * @param name  The name
 * @return The subscriber
 * @throws JMSException Thrown if an error occurs
 */
@Override
public TopicSubscriber createDurableSubscriber(final Topic topic, final String name) throws JMSException {
    if (cri.getType() == ActiveMQRAConnectionFactory.QUEUE_CONNECTION || cri.getType() == ActiveMQRAConnectionFactory.XA_QUEUE_CONNECTION) {
        throw new IllegalStateException("Cannot create durable subscriber from javax.jms.QueueSession");
    }
    lock();
    try {
        Session session = getSessionInternal();
        if (ActiveMQRASession.trace) {
            ActiveMQRALogger.LOGGER.trace("createDurableSubscriber " + session + " topic=" + topic + " name=" + name);
        }
        TopicSubscriber result = session.createDurableSubscriber(topic, name);
        result = new ActiveMQRATopicSubscriber(result, this);
        if (ActiveMQRASession.trace) {
            ActiveMQRALogger.LOGGER.trace("createdDurableSubscriber " + session + " ActiveMQTopicSubscriber=" + result);
        }
        addConsumer(result);
        return result;
    } finally {
        unlock();
    }
}
Also used : TopicSubscriber(javax.jms.TopicSubscriber) 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)

Example 4 with IllegalStateException

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

the class ActiveMQRASession method createQueue.

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

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

the class ActiveMQRASession method createTemporaryQueue.

/**
 * Create a temporary queue
 *
 * @return The temporary queue
 * @throws JMSException Thrown if an error occurs
 */
@Override
public TemporaryQueue createTemporaryQueue() throws JMSException {
    if (cri.getType() == ActiveMQRAConnectionFactory.TOPIC_CONNECTION || cri.getType() == ActiveMQRAConnectionFactory.XA_TOPIC_CONNECTION) {
        throw new IllegalStateException("Cannot create temporary queue for javax.jms.TopicSession");
    }
    lock();
    try {
        Session session = getSessionInternal();
        if (ActiveMQRASession.trace) {
            ActiveMQRALogger.LOGGER.trace("createTemporaryQueue " + session);
        }
        TemporaryQueue temp = session.createTemporaryQueue();
        if (ActiveMQRASession.trace) {
            ActiveMQRALogger.LOGGER.trace("createdTemporaryQueue " + session + " temp=" + temp);
        }
        sf.addTemporaryQueue(temp);
        return temp;
    } finally {
        unlock();
    }
}
Also used : IllegalStateException(javax.jms.IllegalStateException) TemporaryQueue(javax.jms.TemporaryQueue) 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)48 Session (javax.jms.Session)19 Connection (javax.jms.Connection)12 QueueSession (javax.jms.QueueSession)12 Test (org.junit.Test)12 JMSException (javax.jms.JMSException)11 TopicSession (javax.jms.TopicSession)11 XAQueueSession (javax.jms.XAQueueSession)11 XATopicSession (javax.jms.XATopicSession)11 ActiveMQSession (org.apache.activemq.artemis.jms.client.ActiveMQSession)11 SimpleString (org.apache.activemq.artemis.api.core.SimpleString)8 ActiveMQException (org.apache.activemq.artemis.api.core.ActiveMQException)6 IOException (java.io.IOException)5 Truth.assertThat (com.google.common.truth.Truth.assertThat)3 Truth.assertWithMessage (com.google.common.truth.Truth.assertWithMessage)3 RMQJMSException (com.rabbitmq.jms.util.RMQJMSException)3 ChannelHandlerContext (io.netty.channel.ChannelHandlerContext)3 ChannelOutboundHandlerAdapter (io.netty.channel.ChannelOutboundHandlerAdapter)3 ChannelPromise (io.netty.channel.ChannelPromise)3 MqttPubAckMessage (io.netty.handler.codec.mqtt.MqttPubAckMessage)3