throw new javax.jms.IllegalStateException( "setClientID call not supported on proxy for shared Connection. " + "Set the 'clientId' property on the SingleConnectionFactory instead."); throw new javax.jms.IllegalStateException( "setExceptionListener call not supported on proxy for shared Connection. " + "Set the 'exceptionListener' property on the SingleConnectionFactory instead. " + String msg = "JMS Session does not implement specific domain: " + session; try { session.close(); throw new javax.jms.IllegalStateException(msg);
@Override public void unsubscribe(final String name) throws JMSException { // As per spec. section 4.11 if (sessionType == ActiveMQSession.TYPE_QUEUE_SESSION) { throw new IllegalStateException("Cannot unsubscribe using a QueueSession"); } SimpleString queueName = ActiveMQDestination.createQueueNameForSubscription(true, connection.getClientID(), name); try { QueueQuery response = session.queueQuery(queueName); if (!response.isExists()) { throw new InvalidDestinationException("Cannot unsubscribe, subscription with name " + name + " does not exist"); } if (response.getConsumerCount() != 0) { throw new IllegalStateException("Cannot unsubscribe durable subscription " + name + " since it has active subscribers"); } session.deleteQueue(queueName); } catch (ActiveMQException e) { throw JMSExceptionHelper.convertFromActiveMQException(e); } }
public void setClientID(String clientID) { try { if (lockClientID) throw new IllegalStateException("ClientID is already set by the provider."); if (connection == null) throw new JMSException("Underlying connection is closed"); connection.setClientID(clientID); lockClientID = true; } catch (InvalidClientIDException e) { throw new InvalidClientIDRuntimeException(e.getMessage(), e.getErrorCode(), e); } catch (IllegalStateException e) { throw new IllegalStateRuntimeException(e.getMessage(), e.getErrorCode(), e); } catch (JMSException e) { throw new JMSRuntimeException(e.getMessage(), e.getErrorCode(), e); } }
@Override public void setClientID(final String clientID) throws JMSException { checkClosed(); if (this.clientID != null) { throw new IllegalStateException("Client id has already been set"); } if (!justCreated) { throw new IllegalStateException("setClientID can only be called directly after the connection is created"); } validateClientID(initialSession, clientID); this.clientID = clientID; try { this.addSessionMetaData(initialSession); } catch (ActiveMQException e) { JMSException ex = new JMSException("Internal error setting metadata jms-client-id"); ex.setLinkedException(e); ex.initCause(e); throw ex; } justCreated = false; }
public void commit() { connection.lockClientID(); try { session.commit(); } catch (IllegalStateException e) { throw new IllegalStateRuntimeException(e.getMessage()); } catch (JMSException e) { throw new JMSRuntimeException(e.getMessage()); } }
public Queue createQueue(String queueName) throws JMSException { if (info.getType() == JmsConnectionFactory.TOPIC) { throw new IllegalStateException("Cannot create browser or javax.jms.TopicSession"); } Session session = getSession(); if (trace) log.trace("createQueue " + session + " queueName=" + queueName); Queue result = session.createQueue(queueName); if (trace) log.trace("createdQueue " + session + " queue=" + result); return result; }
ClientSession.AddressQuery query = clientSession.addressQuery(address); clientSession.createAddress(address, RoutingType.ANYCAST, true); if (destination.isTemporary()) { clientSession.createTemporaryQueue(address, RoutingType.ANYCAST, address); } else { createQueue(destination, RoutingType.ANYCAST, address, null, true, true, query.getDefaultMaxConsumers(), query.isDefaultPurgeOnNoConsumers(), query.isDefaultExclusive(), query.isDefaultLastValueQueue()); clientSession.createAddress(address, RoutingType.MULTICAST, true); } else if ((destination.isQueue() && !query.isAutoCreateQueues()) || (!destination.isQueue() && !query.isAutoCreateAddresses())) { throw new InvalidDestinationException("Destination " + address + " does not exist"); activeMQJmsMessage.doBeforeSend(); } catch (Exception e) { JMSException je = new JMSException(e.getMessage()); je.initCause(e); JMSException jmsException = new JMSException(e.getMessage()); jmsException.initCause(e); throw jmsException; throw JMSExceptionHelper.convertFromActiveMQException(e); } catch (java.lang.IllegalStateException e) { JMSException je = new IllegalStateException(e.getMessage()); je.setStackTrace(e.getStackTrace()); je.initCause(e);
switch (me.getType()) { case CONNECTION_TIMEDOUT: je = new JMSException(me.getMessage()); break; je = new javax.jms.IllegalStateException(me.getMessage()); break; je = new JMSException(me.getMessage()); break; je = new JMSException(me.getMessage()); break; je = new javax.jms.IllegalStateException(me.getMessage()); break; je = new InvalidDestinationException(me.getMessage()); break; je = new InvalidDestinationException(me.getMessage()); break; je = new javax.jms.IllegalStateException(me.getMessage()); break;
public void deleteTemporaryTopic(final ActiveMQDestination tempTopic) throws JMSException { if (!tempTopic.isTemporary()) { throw new InvalidDestinationException("Not a temporary topic " + tempTopic); } try { AddressQuery response = session.addressQuery(tempTopic.getSimpleAddress()); if (!response.isExists()) { throw new InvalidDestinationException("Cannot delete temporary topic " + tempTopic.getName() + " does not exist"); } if (response.getQueueNames().size() > 1) { throw new IllegalStateException("Cannot delete temporary topic " + tempTopic.getName() + " since it has subscribers"); } SimpleString address = tempTopic.getSimpleAddress(); session.deleteQueue(address); connection.removeTemporaryQueue(address); } catch (ActiveMQException e) { throw JMSExceptionHelper.convertFromActiveMQException(e); } }
public javax.jms.JMSConsumer createSharedConsumer(Topic topic, String sharedSubscriptionName, String messageSelector) { connection.lockClientID(); try { return new JMSConsumer(session.createSharedConsumer(topic, sharedSubscriptionName, messageSelector)); } catch (InvalidDestinationException e) { throw new InvalidDestinationRuntimeException(e.getMessage(), e.getErrorCode(), e); } catch (InvalidSelectorException e) { throw new InvalidSelectorRuntimeException(e.getMessage(), e.getErrorCode(), e); } catch (IllegalStateException e) { throw new IllegalStateRuntimeException(e.getMessage(), e.getErrorCode(), e); } catch (JMSException e) { if (logger.isLoggable(BasicLevel.DEBUG)) logger.log(BasicLevel.DEBUG, "Unable to crate shared consumer " + e.getMessage()); throw new JMSRuntimeException("Unable to create shared consumer " + e.getMessage(), e.getErrorCode(), e); } finally { if (connection.getAutoStart()) connection.start(); } }
public void stop() { try { if (connection == null) throw new JMSException("Underlying connection is closed"); connection.stop(); } catch (IllegalStateException e) { throw new IllegalStateRuntimeException("Unable to close context", e.getMessage(), e); } catch (JMSException e) { throw new JMSRuntimeException("Cannot stop connection", e.getMessage(), e); } }
public Topic createTopic(String topicName) throws JMSException { if (info.getType() == JmsConnectionFactory.QUEUE) { throw new IllegalStateException("Cannot create topic for javax.jms.QueueSession"); } Session session = getSession(); if (trace) log.trace("createTopic " + session + " topicName=" + topicName); Topic result = session.createTopic(topicName); if (trace) log.trace("createdTopic " + session + " topic=" + result); return result; }
@Override public TopicConnection createTopicConnection(String username, String password) throws JMSException { throw new javax.jms.IllegalStateException( "SingleConnectionFactory does not support custom username and password"); }
public void commit() throws JMSException { lock(); try { Session session = getSession(); if (info.isTransacted() == false) throw new IllegalStateException("Session is not transacted"); if (trace) log.trace("Commit session " + this); session.commit(); } finally { unlock(); } }
public JMSConsumer createDurableConsumer(Topic topic, String name, String selector, boolean noLocal) { connection.lockClientID(); try { MessageConsumer consumer = (MessageConsumer) session.createDurableConsumer(topic, name, selector, noLocal); return new JMSConsumer(consumer); } catch (InvalidDestinationException e) { throw new InvalidDestinationRuntimeException(e.getMessage()); } catch (InvalidSelectorException e) { throw new InvalidSelectorRuntimeException(e.getMessage()); } catch (IllegalStateException e) { throw new IllegalStateRuntimeException(e.getMessage()); } catch (JMSException e) { if (logger.isLoggable(BasicLevel.DEBUG)) logger.log(BasicLevel.DEBUG, "Unable to instantiate a JMSConsumer" + e.getMessage()); throw new JMSRuntimeException("Unable to instantiate a JMSConsumer"); } finally { if (connection.getAutoStart()) connection.start(); } }
try { getInternalSession().setMessageListener(null); getInternalSession().rollback(); } catch (JMSException e) { invalidate = true; sessionPool.returnObject(key, sessionHolder); } catch (Exception e) { javax.jms.IllegalStateException illegalStateException = new javax.jms.IllegalStateException(e.toString()); illegalStateException.initCause(e); throw illegalStateException;
public static JMSException convertFromActiveMQException(final ActiveMQInterruptedException me) { JMSException je = new javax.jms.IllegalStateException(me.getMessage()); je.setStackTrace(me.getStackTrace()); je.initCause(me); return je; }
protected void checkClosed() throws IllegalStateException { if (closed.get()) { IllegalStateException jmsEx = null; if (failureCause.get() == null) { jmsEx = new IllegalStateException("The Session is closed"); } else { jmsEx = new IllegalStateException("The Session was closed due to an unrecoverable error."); jmsEx.initCause(failureCause.get()); } throw jmsEx; } }
@Override public TopicSubscriber createDurableSubscriber(final Topic topic, final String name, String messageSelector, final boolean noLocal) throws JMSException { // As per spec. section 4.11 if (sessionType == ActiveMQSession.TYPE_QUEUE_SESSION) { throw new IllegalStateException("Cannot create a durable subscriber on a QueueSession"); } checkTopic(topic); if (!(topic instanceof ActiveMQDestination)) { throw new InvalidDestinationException("Not an ActiveMQTopic:" + topic); } if ("".equals(messageSelector)) { messageSelector = null; } ActiveMQDestination jbdest = (ActiveMQDestination) topic; if (jbdest.isQueue()) { throw new InvalidDestinationException("Cannot create a subscriber on a queue"); } return createConsumer(jbdest, name, messageSelector, noLocal, ConsumerDurability.DURABLE); }
AddressQuery response = session.addressQuery(dest.getSimpleAddress()); throw new InvalidDestinationException("Destination " + dest.getName() + " does not exist"); consumer = session.createConsumer(dest.getSimpleAddress(), coreFilterString, false); } else { AddressQuery response = session.addressQuery(dest.getSimpleAddress()); session.createAddress(dest.getSimpleAddress(), RoutingType.MULTICAST, true); } else { throw new InvalidDestinationException("Topic " + dest.getName() + " does not exist"); throw new RuntimeException("Subscription name must be null for non-durable topic consumer"); if (connection.getClientID() == null) { throw new IllegalStateException("Cannot create durable subscription - client ID has not been set"); throw new InvalidDestinationException("Cannot create a durable subscription on a temporary topic"); throw new IllegalStateException("Cannot create a subscriber on the durable subscription since it already has subscriber(s)");