/** * Build a descriptive exception message for the given JMSException, * incorporating a linked exception's message if appropriate. * @param ex the JMSException to build a message for * @return the descriptive message String * @see javax.jms.JMSException#getLinkedException() */ public static String buildExceptionMessage(JMSException ex) { String message = ex.getMessage(); Exception linkedEx = ex.getLinkedException(); if (linkedEx != null) { if (message == null) { message = linkedEx.toString(); } else { String linkedMessage = linkedEx.getMessage(); if (linkedMessage != null && !message.contains(linkedMessage)) { message = message + "; nested exception is " + linkedEx; } } } return message; }
@Override public void stop() { super.stop(); ArrayList<JMSMessageListenerAdapter> listenerAdapters = listeners.get(pluginId); for (JMSMessageListenerAdapter listenerAdapter : listenerAdapters) { try { listenerAdapter.stop(); } catch (JMSException e) { LOGGER.error("Unable to stop listener for {} {}, ERROR: {}", queueName, listenerAdapter.thread.getName(), e.getMessage(), e); bomb(e); } finally { this.listeners.remove(pluginId); } } } }
@Override public void process(final OutputStream rawOut) throws IOException { try (final OutputStream out = new BufferedOutputStream(rawOut, 65536)) { final byte[] messageBody = JmsFactory.createByteArray(message); out.write(messageBody); } catch (final JMSException e) { throw new ProcessException("Failed to receive JMS Message due to " + e.getMessage(), e); } } });
@Override public int getDeliveryMode() { try { return producer.getDeliveryMode(); } catch (JMSException e) { JMSRuntimeException e2 = new JMSRuntimeException(e.getMessage()); e2.initCause(e); throw e2; } }
@Override public long getTimeToLive() { long timeToLive = 0; try { timeToLive = producer.getTimeToLive(); return timeToLive; } catch (JMSException e) { JMSRuntimeException e2 = new JMSRuntimeException(e.getMessage()); e2.initCause(e); throw e2; } }
@Override public JMSProducer setDeliveryDelay(long deliveryDelay) { try { producer.setDeliveryDelay(deliveryDelay); return this; } catch (JMSException e) { JMSRuntimeException e2 = new JMSRuntimeException(e.getMessage()); e2.initCause(e); throw e2; } }
@Override public JMSProducer setDeliveryMode(int deliveryMode) { try { producer.setDeliveryMode(deliveryMode); } catch (JMSException e) { JMSRuntimeException e2 = new JMSRuntimeException(e.getMessage()); e2.initCause(e); throw e2; } return this; }
@Override public JMSProducer setPriority(int priority) { try { producer.setPriority(priority); } catch (JMSException e) { JMSRuntimeException e2 = new JMSRuntimeException(e.getMessage()); e2.initCause(e); throw e2; } return this; }
@Override public int getPriority() { try { return producer.getPriority(); } catch (JMSException e) { JMSRuntimeException e2 = new JMSRuntimeException(e.getMessage()); e2.initCause(e); throw e2; } }
@Override public JMSProducer setTimeToLive(long timeToLive) { try { producer.setTimeToLive(timeToLive); return this; } catch (JMSException e) { JMSRuntimeException e2 = new JMSRuntimeException(e.getMessage()); e2.initCause(e); throw e2; } }
return new IllegalStateRuntimeException(e.getMessage(), e.getErrorCode(), e); return new InvalidClientIDRuntimeException(e.getMessage(), e.getErrorCode(), e); return new InvalidDestinationRuntimeException(e.getMessage(), e.getErrorCode(), e); return new InvalidSelectorRuntimeException(e.getMessage(), e.getErrorCode(), e); return new JMSSecurityRuntimeException(e.getMessage(), e.getErrorCode(), e); return new MessageFormatRuntimeException(e.getMessage(), e.getErrorCode(), e); return new MessageNotWriteableRuntimeException(e.getMessage(), e.getErrorCode(), e); return new ResourceAllocationRuntimeException(e.getMessage(), e.getErrorCode(), e); return new TransactionInProgressRuntimeException(e.getMessage(), e.getErrorCode(), e); return new TransactionRolledBackRuntimeException(e.getMessage(), e.getErrorCode(), e); return new JMSRuntimeException(e.getMessage(), e.getErrorCode(), e);
@Override public JMSProducer send(Destination destination, byte[] body) { BytesMessage message = context.createBytesMessage(); if (body != null) { try { message.writeBytes(body); } catch (JMSException e) { throw new MessageFormatRuntimeException(e.getMessage()); } } send(destination, message); return this; }
@Override public boolean matches(MessageReference node, MessageEvaluationContext context) throws IOException { ConsumerId targetConsumerId = node.getTargetConsumerId(); if (targetConsumerId != null) { if (!targetConsumerId.equals(info.getConsumerId())) { return false; } } try { return (selectorExpression == null || selectorExpression.matches(context)) && this.context.isAllowedToConsume(node); } catch (JMSException e) { LOG.info("Selector failed to evaluate: {}", e.getMessage(), e); return false; } }
throw new MessageFormatRuntimeException(e.getMessage());
/** * Converts a JMSException from the server to an XAException. if the * JMSException contained a linked XAException that is returned instead. * * @param e JMSException to convert * @return XAException wrapping original exception or its message */ private XAException toXAException(JMSException e) { if (e.getCause() != null && e.getCause() instanceof XAException) { XAException original = (XAException)e.getCause(); XAException xae = new XAException(original.getMessage()); xae.errorCode = original.errorCode; if (xae.errorCode == XA_OK) { // detail not unmarshalled see: org.apache.activemq.openwire.v1.BaseDataStreamMarshaller.createThrowable xae.errorCode = parseFromMessageOr(original.getMessage(), XAException.XAER_RMERR); } xae.initCause(original); return xae; } XAException xae = new XAException(e.getMessage()); xae.errorCode = XAException.XAER_RMFAIL; xae.initCause(e); return xae; }
exception = e; if (logger.isDebugEnabled()) { logger.debug("Connection lost waiting for reply, retrying: " + e.getMessage()); exception = ee; if (logger.isDebugEnabled()) { logger.debug("Could not reconnect, retrying: " + ee.getMessage());
@Override public void onException(final JMSException e) { logger.error("JmsException '{}'", e.getMessage()); } }
@Override public void close() { try { for (Session s : consumerSessions) { s.close(); } connection.close(); } catch (JMSException e) { LOGGER.error("Exception closing JMS connection and consumerSessions: " + e.getMessage()); } } }
public JmsMessage(Message message) { try { initFromMessage(message); } catch (JMSException e) { throw new RuntimeException(e.getMessage(), e); } }
@Override public Message append(Message target, pl.allegro.tech.hermes.consumers.consumer.Message message) { try { for(Map.Entry<String, String> entry : message.getExternalMetadata().entrySet()) { target.setStringProperty(normalize(entry.getKey()), entry.getValue()); } return target; } catch(JMSException e) { throw new JMSRuntimeException(e.getMessage(), e.getErrorCode(), e); } }