/** * Convenience method to get the vendor specific error code if * the root cause was an instance of JMSException. * @return a string specifying the vendor-specific error code if the * root cause is an instance of JMSException, or {@code null} */ @Nullable public String getErrorCode() { Throwable cause = getCause(); if (cause instanceof JMSException) { return ((JMSException) cause).getErrorCode(); } return null; }
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);
private static final String HORNETQ_DISCONNECT_ERROR_CODE = "DISCONNECT"; private void handleExceptions(final JMSException jmsException) { final String errorCode = jmsException.getErrorCode(); if (HORNETQ_DISCONNECT_ERROR_CODE.equals(errorCode)) { tryConnect(); } }
@Override public void onException(JMSException exception) { LOGGER.log(Level.SEVERE, "Exception in JMS Client ID " + clientName + ": " + exception.getMessage() + ". Code: " + exception.getErrorCode(), exception); } });
public class MyConsumer implements ExceptionListener, MessageListener { private void init(){ Connection connection = ... //create connection connection.setExceptionListener(this); connection.start(); } public void onException(JMSException e){ String errorCode = e.getErrorCode(); Exception ex = e.getLinkedException(); //clean up resources, or, attempt to reconnect } public void onMessage(Message m){ ... }
/** * Convenience method to get the vendor specific error code if * the root cause was an instance of JMSException. * @return a string specifying the vendor-specific error code if the * root cause is an instance of JMSException, or {@code null} */ public String getErrorCode() { Throwable cause = getCause(); if (cause instanceof JMSException) { return ((JMSException) cause).getErrorCode(); } return null; }
public void onException(JMSException arg0) { log.error("JMS onException (" + arg0.getErrorCode() + ")", arg0); if(arg0.getLinkedException() != null) log.error("Linked exception ", arg0.getLinkedException()); } }
public static void logJMSException(Logger log, String additionalMessage, JMSException exception) { log.error(additionalMessage + "; (error code = " + exception.getErrorCode() + ")", exception); if (exception.getLinkedException() != null){ log.error("Linked exception ", exception.getLinkedException()); } } }
private void logError( JMSException e ) { if (e.getErrorCode() != null) err.println("error={"+e.getErrorCode()+"} "+e.getMessage()); else err.println(e.getMessage()); if (e.getLinkedException() != null) { err.println("Linked exception was : "); e.getLinkedException().printStackTrace(err); } }
public void onException(JMSException arg0) { log.error("JMS onException (" + arg0.getErrorCode() + ")", arg0); if(arg0.getLinkedException() != null) log.error("Linked exception ", arg0.getLinkedException()); }
/** * Default action on exception receiving. * * @param exception * JMS Exception received on connection. */ protected void onExceptionDefault(JMSException exception) { log.error("JMS onException (error code = " + exception.getErrorCode() + ")", exception); if (exception.getLinkedException() != null) log.error("Linked exception ", exception.getLinkedException()); } }
@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); } }
@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); } }
/** * API method */ public String getMessageSelector() { try { return consumer.getMessageSelector(); } catch (JMSException e) { throw new JMSRuntimeException(e.getMessage(), e.getErrorCode(), e); } }
public void setExceptionListener(ExceptionListener listener) { try { if (connection == null) throw new JMSException("Underlying connection is closed"); connection.setExceptionListener(listener); } catch (JMSException e) { throw new JMSRuntimeException(e.getMessage(), e.getErrorCode(), e); } }
public ConnectionMetaData getMetaData() { try { if (connection == null) throw new JMSException("Underlying connection is closed"); return connection.getMetaData(); } catch (JMSException e) { throw new JMSRuntimeException(e.getMessage(), e.getErrorCode(), e); } }
public ExceptionListener getExceptionListener() { try { if (connection == null) throw new JMSException("Underlying connection is closed"); return connection.getExceptionListener(); } catch (JMSException e) { throw new JMSRuntimeException(e.getMessage(), e.getErrorCode(), e); } }
public String getClientID() { try { if (connection == null) throw new JMSException("Underlying connection is closed"); return connection.getClientID(); } catch (JMSException e) { throw new JMSRuntimeException(e.getMessage(), e.getErrorCode(), e); } }
private void fillHeaders(final Message message, final List<WsJmsMessage.Headers> wsMessage) throws S2JProviderException, S2JProtocolException { for (final WsJmsMessage.Headers entry : wsMessage) { final String valueToBeParsed = entry.getValue(); final Object parsedValue = deserializeValue(valueToBeParsed); try { message.setObjectProperty(entry.getKey(), parsedValue); } catch (final JMSException e) { throw new S2JProviderException(StatusCodeEnum.ERR_JMS, "Error setting jms propertiy [" + entry.getKey() + "] to value [" + parsedValue + "]", e.getErrorCode(), e); } } }
protected final void receiveMessages(JMSConsumer consumer, final int start, final int msgCount, final boolean ack) { try { for (int i = start; i < msgCount; i++) { Message message = consumer.receive(100); Assert.assertNotNull("Expecting a message " + i, message); final int actual = message.getIntProperty("counter"); Assert.assertEquals("expected=" + i + ". Got: property['counter']=" + actual, i, actual); if (ack) message.acknowledge(); } } catch (JMSException cause) { throw new JMSRuntimeException(cause.getMessage(), cause.getErrorCode(), cause); } }