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