@Override public void interrupt() { try { jmsMgr.close(); } catch (MessagingException e) { fail(e.getMessage()); } finally { super.interrupt(); } }
protected void setupProducer(JMSDestination jmsDest) throws MessagingException { if (jmsDest.producer != null) return; try { jmsDest.producer = jmsDest.session.createProducer(jmsDest.destination); } catch (JMSException e) { throw new MessagingException(e.getMessage(), e); } }
throw new MessagingException("No destinations available for " + "subscription, make sure that there is at least one topic " + "or queue specified in the connection properties."); logger.error("MessagingException encountered attempting to start " + "Messaging Client: " + m_clientId + ". Exception message: " + me.getMessage(), me); throw me;
m_jmsManager = new JMSManager(m_connectionProperties, m_clientId); } catch(MessagingException me) { Throwable rootCause = me.getCause(); while(rootCause.getCause() != null) { rootCause = rootCause.getCause();
protected void setupProducer(JMSDestination jmsDest) throws MessagingException { if (jmsDest.producer != null) return; try { jmsDest.producer = jmsDest.session.createProducer(jmsDest.destination); } catch (JMSException e) { throw new MessagingException(e.getMessage(), e); } }
@Override public void run() { try { jmsMgr.listen("fedora.apim.update", this); } catch (MessagingException e) { fail(e.getMessage()); } finally { listeningSignal.countDown(); } }
protected Object jndiLookup(String name) throws MessagingException { if (jndi == null) { jndi = getContext(); } try { return jndi.lookup(name); } catch (NamingException e) { throw new MessagingException("jndiLookup(" + name + ") failed: " + e.getMessage(), e); } }
/** * Stops the MessagingClient, shuts down connections. If the unsubscribe * parameter is set to true, all durable subscriptions will be removed. * * @param unsubscribe */ public void stop(boolean unsubscribe) throws MessagingException { try { if (unsubscribe) { m_jmsManager.unsubscribeAllDurable(); } m_jmsManager.close(); m_jmsManager = null; m_connected = false; } catch (MessagingException me) { logger.error("Messaging Exception encountered attempting to stop " + "Messaging Client: " + m_clientId + ". Exception message: " + me.getMessage(), me); throw me; } }
protected Object jndiLookup(String name) throws MessagingException { if (jndi == null) { jndi = getContext(); } try { return jndi.lookup(name); } catch (NamingException e) { throw new MessagingException("jndiLookup(" + name + ") failed: " + e.getMessage(), e); } }
@Override public void shutdownModule() throws ModuleShutdownException { if(enabled()) { try { close(); } catch (MessagingException e) { throw new ModuleShutdownException(e.getMessage(), getRole(), e); } } }
/** * Allows the caller to send a Message object to a destination */ public void send(Destination dest, Message msg) throws MessagingException { try { Session s = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); MessageProducer p = s.createProducer(dest); p.send(msg); s.close(); } catch (JMSException e) { throw new MessagingException(e.getMessage(), e); } if(logger.isDebugEnabled()) { logger.debug("send() - message sent to destination " + dest); } }
@Override public void shutdownModule() throws ModuleShutdownException { if(enabled()) { try { close(); } catch (MessagingException e) { throw new ModuleShutdownException(e.getMessage(), getRole(), e); } } }
/** * Allows the caller to send a Message object to a destination */ public void send(Destination dest, Message msg) throws MessagingException { try { Session s = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); MessageProducer p = s.createProducer(dest); p.send(msg); s.close(); } catch (JMSException e) { throw new MessagingException(e.getMessage(), e); } if(logger.isDebugEnabled()) { logger.debug("send() - message sent to destination " + dest); } }
"should throw an exception"); } catch(MessagingException expected) { assertTrue(expected.getMessage().contains("properties")); "should throw an exception"); } catch(MessagingException expected) { assertTrue(expected.getMessage().contains(Context.INITIAL_CONTEXT_FACTORY)); "property should throw an exception"); } catch(MessagingException expected) { assertTrue(expected.getMessage().contains(Context.PROVIDER_URL)); "property should throw an exception"); } catch(MessagingException expected) { assertTrue(expected.getMessage().contains(Context.INITIAL_CONTEXT_FACTORY));
protected Message setupSynchConsumer(JMSDestination jmsDest, String messageSelector, int timeout) throws MessagingException { try { if (jmsDest.consumer == null) { jmsDest.consumer = jmsDest.session.createConsumer(jmsDest.destination, messageSelector); } if (timeout > 0) return jmsDest.consumer.receive(timeout); else return jmsDest.consumer.receive(); } catch (JMSException e) { throw new MessagingException(e.getMessage(), e); } }
protected Message setupSynchConsumer(JMSDestination jmsDest, String messageSelector, int timeout) throws MessagingException { try { if (jmsDest.consumer == null) { jmsDest.consumer = jmsDest.session.createConsumer(jmsDest.destination, messageSelector); } if (timeout > 0) return jmsDest.consumer.receive(timeout); else return jmsDest.consumer.receive(); } catch (JMSException e) { throw new MessagingException(e.getMessage(), e); } }
public void close() throws MessagingException { try { // Closing a connection also closes all sessions, producers, // and consumers established over that connection connection.stop(); connection.close(); connected = false; logger.debug("Connection closed."); } catch (JMSException e) { logger.debug("Error closing Connection."); throw new MessagingException(e.getMessage(), e); } }
public void close() throws MessagingException { try { // Closing a connection also closes all sessions, producers, // and consumers established over that connection connection.stop(); connection.close(); connected = false; logger.debug("Connection closed."); } catch (JMSException e) { logger.debug("Error closing Connection."); throw new MessagingException(e.getMessage(), e); } }
protected Connection getConnection() throws MessagingException { ConnectionFactory connectionFactory; if (jndiProps != null) { String connectionFactoryName = jndiProps.getProperty(CONNECTION_FACTORY_NAME); if(connectionFactoryName == null || connectionFactoryName.isEmpty()) { connectionFactoryName = defaultConnectionFactoryName; } connectionFactory = (ConnectionFactory) jndiLookup(connectionFactoryName); } else { throw new MessagingException("Unable to create JMS connection " + "because JNDI properties were not initialized."); } try { connection = connectionFactory.createConnection(); } catch (JMSException e) { throw new MessagingException(e.getMessage(), e); } return connection; }
protected Connection getConnection() throws MessagingException { ConnectionFactory connectionFactory; if (jndiProps != null) { String connectionFactoryName = jndiProps.getProperty(CONNECTION_FACTORY_NAME); if(connectionFactoryName == null || connectionFactoryName.isEmpty()) { connectionFactoryName = defaultConnectionFactoryName; } connectionFactory = (ConnectionFactory) jndiLookup(connectionFactoryName); } else { throw new MessagingException("Unable to create JMS connection " + "because JNDI properties were not initialized."); } try { connection = connectionFactory.createConnection(); } catch (JMSException e) { throw new MessagingException(e.getMessage(), e); } return connection; }