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();
}
}
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;
}
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();
}
}
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;
}
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();
}
}
Aggregations