List of usage examples for javax.jms JMSException JMSException
public JMSException(String reason)
From source file:org.dhatim.routing.jms.activemq.ActiveMQProvider.java
private void createTopicSession() throws JMSException { try {// ww w . j a va 2 s . c o m ConnectionFactory connectionFactory = getConnectionFactory(); topicConnection = ((TopicConnectionFactory) connectionFactory).createTopicConnection(); topicSession = ((TopicConnection) topicConnection).createTopicSession(false, TopicSession.AUTO_ACKNOWLEDGE); // Start the connection... topicConnection.start(); } catch (JMSException e) { close(topicConnection, topicSession); throw e; } catch (Throwable t) { close(topicConnection, topicSession); throw (JMSException) (new JMSException("Unexpected exception while creating JMS Session.") .initCause(t)); } }
From source file:org.dhatim.routing.jms.activemq.ActiveMQProvider.java
private ConnectionFactory getConnectionFactory() throws JMSException { String connectionFactoryRuntime = jndiProperties.getProperty(ConnectionFactory.class.getName(), "ConnectionFactory"); try {// w w w . j a va 2 s .c o m return (ConnectionFactory) JNDIUtil.lookup(connectionFactoryRuntime, jndiProperties); } catch (NamingException e) { throw (JMSException) (new JMSException( "JNDI lookup of JMS Connection Factory [" + connectionFactoryRuntime + "] failed.") .initCause(e)); } catch (ClassCastException e) { throw (JMSException) (new JMSException( "JNDI lookup of JMS Connection Factory failed. Class [" + connectionFactoryRuntime + "] is not an instance of [" + ConnectionFactory.class.getName() + "].").initCause(e)); } }
From source file:org.dhatim.routing.jms.activemq.ActiveMQProvider.java
private final Destination lookupDestination(String destinationName) throws JMSException { try {// w w w. jav a 2 s . com return (Destination) JNDIUtil.lookup(destinationName, jndiProperties); } catch (NamingException e) { throw (JMSException) (new JMSException( "JMS Destination lookup failed. Destination name '" + destinationName + "'.").initCause(e)); } catch (ClassCastException e) { throw (JMSException) (new JMSException("JMS Destination lookup failed. Class [" + destinationName + "] is not an instance of [" + Destination.class.getName() + "].").initCause(e)); } }
From source file:org.frameworkset.mq.ReceiveDispatcher.java
private void assertStarted() throws JMSException { if (this.session == null) { throw new JMSException("MQClient has not been started."); }/*from ww w. j av a2s.com*/ }
From source file:org.frameworkset.mq.ReceiveDispatcher.java
public MessageConsumer getConsumer() throws JMSException { if (this.destinationType == MQUtil.TYPE_ROUTER) throw new JMSException( "?,????.type=" + MQUtil.getTypeDesc(destinationType)); if (consumer != null) return consumer; synchronized (consumerLock) { if (consumer != null) return consumer; return consumer = getConsumer(destinationType, destination); }//from w ww . ja v a2 s.c o m }
From source file:org.frameworkset.mq.ReceiveDispatcher.java
public MessageConsumer getConsumerWithSelector(String selector) throws JMSException { if (this.destinationType == MQUtil.TYPE_ROUTER) throw new JMSException( "?,????.type=" + MQUtil.getTypeDesc(destinationType)); if (this.messageSelector != null && this.messageSelector.equals(selector))// ??? return this.consumer; if (this.consumer != null) throw new JMSException("???other selector is " + this.messageSelector); synchronized (consumerLock) { if (this.messageSelector != null && this.messageSelector.equals(selector))// ??? return this.consumer; if (this.consumer != null) throw new JMSException("???other selector is " + this.messageSelector); this.consumer = getConsumer(destinationType, destination, selector, false); this.messageSelector = selector; }/*from ww w . j a va 2 s .c om*/ return this.consumer; }
From source file:org.frameworkset.mq.ReceiveDispatcher.java
private void assertConsumerNull() throws JMSException { if (this.consumer == null) { throw new JMSException("consumer == null"); }/*from w ww .ja va 2 s . c o m*/ }
From source file:org.frameworkset.mq.RequestDispatcher.java
private void assertStarted() throws JMSException { if (this.session == null) { throw new JMSException("MQClient has not been started."); }//w w w .j av a2s .co m }
From source file:org.frameworkset.mq.RequestDispatcher.java
public void send(int destinationType, String destination_, boolean persistent, int priority, long timeToLive, Message message, Logger step, JMSProperties properties) throws JMSException { if (step != null) step.logBasic("send message to " + destination_ + " assertStarted(),message=" + message); assertStarted();// w ww.j a va 2 s. c om MessageProducer producer = null; try { Destination destination = null; // boolean isqueue = destinationType == MQUtil.TYPE_QUEUE; // if (isqueue) // { // if(step != null) // step.logBasic("send message to " + destination_ // + " build QUEUE destination"); // destination = session.createQueue(destination_); // if(step != null) // step.logBasic("send message to " + destination_ // + " build QUEUE destination end"); // } // else // { // if(step != null) // step.logBasic("send message to " + destination_ // + " build Topic destination"); // destination = session.createTopic(destination_); // if(step != null) // step.logBasic("send message to " + destination_ // + " build Topic destination end"); // } if (step != null) step.logBasic("send message to " + destination_ + " build destination."); destination = this.connection.createDestination(session, destination_, destinationType); if (step != null) step.logBasic("send message to " + destination_ + " build destination end"); int deliveryMode = persistent ? DeliveryMode.PERSISTENT : DeliveryMode.NON_PERSISTENT; if (step != null) step.logBasic("send message to " + destination_ + " this.client.isPersistent =" + persistent); if (step != null) step.logBasic("send message to " + destination + " send started...."); producer = session.createProducer(destination); if (properties != null) MQUtil.initMessage(message, properties); producer.send(message, deliveryMode, priority, timeToLive); if (step != null) step.logBasic("send message to " + destination + " send end...."); if (LOG.isDebugEnabled()) { LOG.debug("Sent! to destination: " + destination + " message: " + message); } } catch (JMSException e) { throw e; } catch (Exception e) { throw new JMSException(e.getMessage()); } finally { if (producer != null) try { producer.close(); } catch (Exception e) { } } }
From source file:org.frameworkset.mq.RequestDispatcher.java
public void send(int destinationType, String destination_, boolean persistent, int priority, long timeToLive, Message message, JMSProperties properties) throws JMSException { LOG.debug("send message to " + destination_ + " assertStarted(),message=" + message); assertStarted();/*from w w w.ja va2 s.c o m*/ MessageProducer producer = null; try { Destination destination = null; // destinationType = JMSConnectionFactory.evaluateDestinationType(destination_, destinationType); // destination_ = JMSConnectionFactory.evaluateDestination(destination_); // boolean isqueue = destinationType == MQUtil.TYPE_QUEUE; // if (isqueue) // { // LOG.debug("send message to " + destination_ // + " build QUEUE destination"); // destination = session.createQueue(destination_); // LOG.debug("send message to " + destination_ // + " build QUEUE destination end"); // } // else // { // LOG.debug("send message to " + destination_ // + " build Topic destination"); // destination = session.createTopic(destination_); // LOG.debug("send message to " + destination_ // + " build Topic destination end"); // } LOG.debug("send message to " + destination_ + " build destination"); destination = connection.createDestination(session, destination_, destinationType); LOG.debug("send message to " + destination_ + " build destination end."); int deliveryMode = persistent ? DeliveryMode.PERSISTENT : DeliveryMode.NON_PERSISTENT; LOG.debug("send message to " + destination_ + " this.client.isPersistent =" + persistent); LOG.debug("send message to " + destination + " send started...."); producer = session.createProducer(destination); if (properties != null) MQUtil.initMessage(message, properties); producer.send(message, deliveryMode, priority, timeToLive); LOG.debug("send message to " + destination + " send end...."); if (LOG.isDebugEnabled()) { LOG.debug("Sent! to destination: " + destination + " message: " + message); } } catch (JMSException e) { throw e; } catch (Exception e) { throw new JMSException(e.getMessage()); } finally { if (producer != null) try { producer.close(); } catch (Exception e) { } } }