Example usage for javax.jms JMSException setLinkedException

List of usage examples for javax.jms JMSException setLinkedException

Introduction

In this page you can find the example usage for javax.jms JMSException setLinkedException.

Prototype

public void setLinkedException(Exception ex) 

Source Link

Document

Adds a linked Exception .

Usage

From source file:org.fusesource.camel.util.BlobMessageConverter.java

@Override
public Object fromMessage(Message message) throws JMSException, MessageConversionException {
    if (message instanceof BlobMessage) {
        try {/*from  ww  w. java  2 s. c o  m*/
            return ((BlobMessage) message).getInputStream();
        } catch (IOException e) {
            JMSException jmsE = new JMSException("Unable to read blob message.");
            jmsE.setLinkedException(e);
            throw jmsE;
        }
    } else {
        throw new MessageConversionException("Message must be of type ActiveMQBlobMessage.");
    }
}

From source file:com.mothsoft.alexis.engine.textual.ParseResponseMessageListener.java

@Override
public void onMessage(final TextMessage message, final Session session) throws JMSException {

    final long documentId = message.getLongProperty(DOCUMENT_ID);
    logger.info("Received response for document ID: " + documentId);

    final String xml = message.getText();

    try {/* w  w  w  . java2s. c o  m*/
        final ParsedContent parsedContent = readResponse(xml);
        updateDocument(documentId, parsedContent);
    } catch (final IOException e) {
        final JMSException e2 = new JMSException(e.getMessage());
        e2.setLinkedException(e);
        throw e2;
    }
}

From source file:org.apache.servicemix.jbi.cluster.requestor.AbstractJmsRequestorPool.java

private JMSException fixForSpring5470(JMSException ex) {
    if (ex.getCause() != null && ex.getCause().getMessage() == null) {
        ex.setLinkedException(new Exception("Unknown", ex.getCause()));
    }/*from   w  w w  . java2s.  c o  m*/
    return ex;
}

From source file:org.apache.activemq.jms.pool.PooledConnectionFactory.java

private JMSException createJmsException(String msg, Exception cause) {
    JMSException exception = new JMSException(msg);
    exception.setLinkedException(cause);
    exception.initCause(cause);/*  www .  j  a v a  2 s.c o m*/
    return exception;
}

From source file:org.apache.hedwig.jms.spi.HedwigConnectionImpl.java

private ClientConfiguration loadConfig() throws JMSException {
    ClientConfiguration config = new ClientConfiguration();

    // TODO: This is not very extensible and useful ... we need to pick the info from
    // configuration specified by user, NOT only from static files !
    // Also, we need to be able to support multiple configuration in a single client !
    // We need a better solution ....

    try {/*w  w w .  ja v  a 2 s  .  c om*/
        // 1. try to load the client configuration as specified from a
        // system property
        if (System.getProperty(HEDWIG_CLIENT_CONFIG_FILE) != null) {
            File configFile = new File(System.getProperty(HEDWIG_CLIENT_CONFIG_FILE));
            if (!configFile.exists()) {
                throw new JMSException(
                        "Cannot create connection: cannot find Hedwig client configuration file specified as ["
                                + System.getProperty(HEDWIG_CLIENT_CONFIG_FILE) + "]");
            }
            config.loadConf(configFile.toURI().toURL());
        } else {
            // 2. try to load a "hedwig-client.cfg" file from the classpath
            config.loadConf(new URL(null, "classpath://hedwig-client.cfg", new URLStreamHandler() {
                protected URLConnection openConnection(URL u) throws IOException {
                    // rely on the relevant classloader - not system classloader.
                    final URL resourceUrl = HedwigConnectionImpl.this.getClass().getClassLoader()
                            .getResource(u.getPath());
                    return resourceUrl.openConnection();
                }
            }));
        }

    } catch (MalformedURLException e) {
        JMSException je = new JMSException("Cannot load Hedwig client configuration file " + e);
        je.setLinkedException(e);
        throw je;
    } catch (ConfigurationException e) {
        JMSException je = new JMSException("Cannot load Hedwig client configuration " + e);
        je.setLinkedException(e);
        throw je;
    }

    /*
    System.out.println("getConsumedMessagesBufferSize : " + config.getConsumedMessagesBufferSize());
    System.out.println("getDefaultServerHost : " + config.getDefaultServerHost());
    System.out.println("isSSLEnabled : " + config.isSSLEnabled());
    System.out.println("getMaximumMessageSize : " + config.getMaximumMessageSize());
    System.out.println("getMaximumOutstandingMessages : " + config.getMaximumOutstandingMessages());
    System.out.println("getMaximumServerRedirects : "  + config.getMaximumServerRedirects());
    System.out.println("getServerAckResponseTimeout : "  + config.getServerAckResponseTimeout());
    */

    return config;
}

From source file:org.logicblaze.lingo.jms.impl.MultiplexingRequestor.java

protected JMSException createJMSException(Exception e) {
    JMSException answer = new JMSException(e.toString());
    answer.setLinkedException(e);
    return answer;
}

From source file:org.skyscreamer.nevado.jms.message.NevadoBytesMessage.java

/**
 * Reads a <code>boolean</code> from the bytes message stream.
 *
 * @return the <code>boolean</code> value read
 * @throws JMSException                if the JMS provider fails to read the message due to some internal error.
 * @throws MessageEOFException         if unexpected end of bytes stream has been reached.
 * @throws MessageNotReadableException if the message is in write-only mode.
 *///w  w w  .jav  a2  s  .com
public boolean readBoolean() throws JMSException {
    initializeReading();
    try {
        return this.dataIn.readBoolean();
    } catch (EOFException eof) {
        JMSException jmsEx = new MessageEOFException(eof.getMessage());
        jmsEx.setLinkedException(eof);
        throw jmsEx;
    } catch (IOException ioe) {
        JMSException jmsEx = new JMSException("Format error occured" + ioe.getMessage());
        jmsEx.setLinkedException(ioe);
        throw jmsEx;
    }
}

From source file:org.skyscreamer.nevado.jms.message.NevadoBytesMessage.java

/**
 * Reads a signed 8-bit value from the bytes message stream.
 *
 * @return the next byte from the bytes message stream as a signed 8-bit <code>byte</code>
 * @throws JMSException                if the JMS provider fails to read the message due to some internal error.
 * @throws MessageEOFException         if unexpected end of bytes stream has been reached.
 * @throws MessageNotReadableException if the message is in write-only mode.
 *//*from   w w  w  .  j av  a  2  s .  c  o  m*/
public byte readByte() throws JMSException {
    initializeReading();
    try {
        return this.dataIn.readByte();
    } catch (EOFException eof) {
        JMSException jmsEx = new MessageEOFException(eof.getMessage());
        jmsEx.setLinkedException(eof);
        throw jmsEx;
    } catch (IOException ioe) {
        JMSException jmsEx = new JMSException("Format error occured" + ioe.getMessage());
        jmsEx.setLinkedException(ioe);
        throw jmsEx;
    }
}

From source file:org.skyscreamer.nevado.jms.message.NevadoBytesMessage.java

/**
 * Reads an unsigned 8-bit number from the bytes message stream.
 *
 * @return the next byte from the bytes message stream, interpreted as an unsigned 8-bit number
 * @throws JMSException                if the JMS provider fails to read the message due to some internal error.
 * @throws MessageEOFException         if unexpected end of bytes stream has been reached.
 * @throws MessageNotReadableException if the message is in write-only mode.
 *//*from w  ww  .jav  a2s.  c o m*/
public int readUnsignedByte() throws JMSException {
    initializeReading();
    try {
        return this.dataIn.readUnsignedByte();
    } catch (EOFException eof) {
        JMSException jmsEx = new MessageEOFException(eof.getMessage());
        jmsEx.setLinkedException(eof);
        throw jmsEx;
    } catch (IOException ioe) {
        JMSException jmsEx = new JMSException("Format error occured" + ioe.getMessage());
        jmsEx.setLinkedException(ioe);
        throw jmsEx;
    }
}

From source file:org.skyscreamer.nevado.jms.message.NevadoBytesMessage.java

/**
 * Reads a signed 16-bit number from the bytes message stream.
 *
 * @return the next two bytes from the bytes message stream, interpreted as a signed 16-bit number
 * @throws JMSException                if the JMS provider fails to read the message due to some internal error.
 * @throws MessageEOFException         if unexpected end of bytes stream has been reached.
 * @throws MessageNotReadableException if the message is in write-only mode.
 *//*from  w w  w  .j av  a  2  s  . co  m*/
public short readShort() throws JMSException {
    initializeReading();
    try {
        return this.dataIn.readShort();
    } catch (EOFException eof) {
        JMSException jmsEx = new MessageEOFException(eof.getMessage());
        jmsEx.setLinkedException(eof);
        throw jmsEx;
    } catch (IOException ioe) {
        JMSException jmsEx = new JMSException("Format error occured" + ioe.getMessage());
        jmsEx.setLinkedException(ioe);
        throw jmsEx;
    }
}