List of usage examples for javax.jms JMSException getLocalizedMessage
public String getLocalizedMessage()
From source file:org.apache.flink.streaming.connectors.jms.JmsQueueSink.java
@Override public void invoke(final T object) throws Exception { try {// w ww. ja v a2 s . c o m producer.send(destination, convert(object, session), Message.DEFAULT_DELIVERY_MODE, Message.DEFAULT_PRIORITY, Message.DEFAULT_TIME_TO_LIVE); } catch (JMSException e) { logger.error("Error sending message to [{}]: {}", destination.getQueueName(), e.getLocalizedMessage()); throw new UncategorizedJmsException(e); } }
From source file:org.apache.flink.streaming.connectors.jms.JmsTopicSink.java
@Override public void invoke(final T object) throws Exception { try {//from www . j av a2 s . com producer.publish(destination, convert(object, session), Message.DEFAULT_DELIVERY_MODE, Message.DEFAULT_PRIORITY, Message.DEFAULT_TIME_TO_LIVE); } catch (JMSException e) { logger.error("Error sending message to [{}]: {}", destination.getTopicName(), e.getLocalizedMessage(), e); throw new UncategorizedJmsException(e); } }
From source file:org.apache.flink.streaming.connectors.jms.JmsQueueSource.java
@Override public void run(final SourceContext<T> context) throws Exception { QueueSession session = null;/*from ww w . j a v a 2 s . c om*/ QueueReceiver consumer = null; try { session = connection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE); consumer = session.createReceiver(destination, messageSelector); connection.start(); while (isRunning) { context.collect(convert(consumer.receive())); } } catch (JMSException e) { logger.error("Error receiving message from [{}]: {}", destination.getQueueName(), e.getLocalizedMessage()); throw new UncategorizedJmsException(e); } finally { JmsUtils.closeMessageConsumer(consumer); JmsUtils.closeSession(session); } }
From source file:org.apache.flink.streaming.connectors.jms.JmsTopicSource.java
@Override public void run(final SourceContext<T> context) throws Exception { TopicSession session = null;//from w w w . j ava2s . com TopicSubscriber consumer = null; try { session = connection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE); consumer = session.createSubscriber(destination, messageSelector, false); connection.start(); while (isRunning) { context.collect(convert(consumer.receive())); } } catch (JMSException e) { logger.error("Error receiving message from [{}]: {}", destination.getTopicName(), e.getLocalizedMessage()); throw new UncategorizedJmsException(e); } finally { JmsUtils.closeMessageConsumer(consumer); JmsUtils.closeSession(session); } }
From source file:com.datatorrent.lib.io.jms.ActiveMQBase.java
/** * cleanup connection resources.//ww w.j a v a2 s . c o m */ protected void cleanup() { try { session.close(); connection.close(); session = null; connection = null; } catch (JMSException ex) { logger.debug(ex.getLocalizedMessage()); } }
From source file:com.datatorrent.lib.io.jms.AbstractJMSInputOperator.java
/** * If getJMSReplyTo is set then send message back to reply producer. * * @param message/*from w ww . j a v a 2 s .co m*/ */ protected void sendReply(Message message) { try { if (message.getJMSReplyTo() != null) { // Send reply only if the replyTo destination is set replyProducer.send(message.getJMSReplyTo(), getSession().createTextMessage("Reply: " + message.getJMSMessageID())); } } catch (JMSException ex) { LOG.error(ex.getLocalizedMessage()); throwable.set(ex); throw new RuntimeException(ex); } }
From source file:com.datatorrent.lib.io.jms.AbstractJMSInputOperator.java
/** * Implementation of {@link ExceptionListener} * * @param ex//from w w w . j a va2 s. c o m */ @Override public void onException(JMSException ex) { cleanup(); LOG.error(ex.getLocalizedMessage()); throwable.set(ex); throw new RuntimeException(ex); }
From source file:com.chakray.chilcano.wso2.rabbitmq.message.store.RabbitMQConsumer.java
public MessageContext receive() { boolean error; JMSException exception; if (!checkConnection()) { if (!reconnect()) { if (logger.isDebugEnabled()) { logger.debug(getId() + " cannot receive message from store. Cannot reconnect."); }/*from www . j av a 2 s . com*/ return null; } else { logger.info(getId() + " reconnected to store."); isReceiveError = false; } } if (!checkConnection()) { if (logger.isDebugEnabled()) { logger.debug(getId() + " cannot receive message from store."); } return null; } try { Message message = consumer.receive(3000); if (message == null) { return null; } if (!(message instanceof ObjectMessage)) { logger.warn(getId() + ". Did not receive a javax.jms.ObjectMessage"); message.acknowledge(); // TODO: return null; } ObjectMessage msg = (ObjectMessage) message; String messageId = msg.getStringProperty(Constants.OriginalMessageID); if (!(msg.getObject() instanceof StorableMessage)) { logger.warn(getId() + ". Did not receive a valid message."); message.acknowledge(); return null; } StorableMessage storableMessage = (StorableMessage) msg.getObject(); org.apache.axis2.context.MessageContext axis2Mc = store.newAxis2Mc(); MessageContext synapseMc = store.newSynapseMc(axis2Mc); synapseMc = MessageConverter.toMessageContext(storableMessage, axis2Mc, synapseMc); updateCache(message, synapseMc, messageId, false); if (logger.isDebugEnabled()) { logger.debug( getId() + " Received MessageId:" + messageId + " priority:" + message.getJMSPriority()); } return synapseMc; } catch (JMSException e) { error = true; exception = e; } if (error) { if (!isReceiveError) { logger.error( getId() + " cannot receive message from store. Error:" + exception.getLocalizedMessage());//, exception); } updateCache(null, null, "", true); cleanup(); return null; } return null; }
From source file:org.apache.qpid.disttest.jms.ClientJmsDelegate.java
public void startConnections() { // start connections for consumers // it would be better if we could track consumer connections and start // only those if (!_testConsumers.isEmpty()) { for (final Map.Entry<String, Connection> entry : _testConnections.entrySet()) { final Connection connection = entry.getValue(); try { connection.start();//from w w w.j a va2s . c o m } catch (final JMSException e) { throw new DistributedTestException( "Failed to start connection '" + entry.getKey() + "' :" + e.getLocalizedMessage()); } } } }
From source file:org.apache.qpid.disttest.jms.ClientJmsDelegate.java
public void tearDownTest() { StringBuilder jmsErrorMessages = new StringBuilder(); int failureCounter = 0; for (String subscription : _testSubscriptions.keySet()) { Session session = _testSubscriptions.get(subscription); try {//from w w w .ja v a 2 s. c o m session.unsubscribe(subscription); } catch (JMSException e) { LOGGER.error("Failed to unsubscribe '" + subscription + "' :" + e.getLocalizedMessage(), e); failureCounter++; appendErrorMessage(jmsErrorMessages, e); } } for (Map.Entry<String, Connection> entry : _testConnections.entrySet()) { Connection connection = entry.getValue(); try { connection.close(); } catch (JMSException e) { LOGGER.error("Failed to close connection '" + entry.getKey() + "' :" + e.getLocalizedMessage(), e); failureCounter++; appendErrorMessage(jmsErrorMessages, e); } } _testConnections.clear(); _testSubscriptions.clear(); _testSessions.clear(); _testProducers.clear(); _testConsumers.clear(); if (failureCounter > 0) { throw new DistributedTestException("Tear down test encountered " + failureCounter + " failures with the following errors: " + jmsErrorMessages.toString()); } }