Example usage for javax.jms JMSException JMSException

List of usage examples for javax.jms JMSException JMSException

Introduction

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

Prototype

public JMSException(String reason) 

Source Link

Document

Constructs a JMSException with the specified reason and with the error code defaulting to null.

Usage

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

/**
 * Writes a <code>long</code> to the bytes message stream as eight bytes, high byte first.
 *
 * @param value the <code>long</code> to be written
 * @throws JMSException                 if the JMS provider fails to write the message due to some internal error.
 * @throws MessageNotWriteableException if the message is in read-only mode.
 */// ww  w  .j a v  a  2 s . co m
public void writeLong(long value) throws JMSException {
    initializeWriting();
    try {
        this.dataOut.writeLong(value);
    } catch (IOException ioe) {
        JMSException jmsEx = new JMSException("Could not write data:" + ioe.getMessage());
        jmsEx.setLinkedException(ioe);
        throw jmsEx;
    }
}

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

/**
 * Converts the <code>float</code> argument to an <code>int</code> using the <code>floatToIntBits</code>
 * method in class <code>Float</code>, and then writes that <code>int</code> value to the bytes message stream
 * as a 4-byte quantity, high byte first.
 *
 * @param value the <code>float</code> value to be written
 * @throws JMSException                 if the JMS provider fails to write the message due to some internal error.
 * @throws MessageNotWriteableException if the message is in read-only mode.
 *//*from ww w  .  j  a v a 2 s. c  om*/
public void writeFloat(float value) throws JMSException {
    initializeWriting();
    try {
        this.dataOut.writeFloat(value);
    } catch (IOException ioe) {
        JMSException jmsEx = new JMSException("Could not write data:" + ioe.getMessage());
        jmsEx.setLinkedException(ioe);
        throw jmsEx;
    }
}

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

/**
 * Converts the <code>double</code> argument to a <code>long</code> using the <code>doubleToLongBits</code>
 * method in class <code>Double</code>, and then writes that <code>long</code> value to the bytes message
 * stream as an 8-byte quantity, high byte first.
 *
 * @param value the <code>double</code> value to be written
 * @throws JMSException                 if the JMS provider fails to write the message due to some internal error.
 * @throws MessageNotWriteableException if the message is in read-only mode.
 *//*from   ww w. j  ava2s.  c o m*/
public void writeDouble(double value) throws JMSException {
    initializeWriting();
    try {
        this.dataOut.writeDouble(value);
    } catch (IOException ioe) {
        JMSException jmsEx = new JMSException("Could not write data:" + ioe.getMessage());
        jmsEx.setLinkedException(ioe);
        throw jmsEx;
    }
}

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

/**
 * Writes a string to the bytes message stream using UTF-8 encoding in a machine-independent manner.
 * <P>/*  w w  w  . j  ava 2  s .c  om*/
 * For more information on the UTF-8 format, see "File System Safe UCS Transformation Format (FSS_UTF)", X/Open
 * Preliminary Specification, X/Open Company Ltd., Document Number: P316. This information also appears in ISO/IEC
 * 10646, Annex P.
 *
 * @param value the <code>String</code> value to be written
 * @throws JMSException                 if the JMS provider fails to write the message due to some internal error.
 * @throws MessageNotWriteableException if the message is in read-only mode.
 */
public void writeUTF(String value) throws JMSException {
    initializeWriting();
    try {
        this.dataOut.writeUTF(value);
    } catch (IOException ioe) {
        JMSException jmsEx = new JMSException("Could not write data:" + ioe.getMessage());
        jmsEx.setLinkedException(ioe);
        throw jmsEx;
    }
}

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

/**
 * Writes a byte array to the bytes message stream.
 *
 * @param value the byte array to be written
 * @throws JMSException                 if the JMS provider fails to write the message due to some internal error.
 * @throws MessageNotWriteableException if the message is in read-only mode.
 *//*www.jav a  2 s  .c  o  m*/
public void writeBytes(byte[] value) throws JMSException {
    initializeWriting();
    try {
        this.dataOut.write(value);
    } catch (IOException ioe) {
        JMSException jmsEx = new JMSException("Could not write data:" + ioe.getMessage());
        jmsEx.setLinkedException(ioe);
        throw jmsEx;
    }
}

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

/**
 * Writes a portion of a byte array to the bytes message stream.
 *
 * @param value  the byte array value to be written
 * @param offset the initial offset within the byte array
 * @param length the number of bytes to use
 * @throws JMSException                 if the JMS provider fails to write the message due to some internal error.
 * @throws MessageNotWriteableException if the message is in read-only mode.
 */// ww w . j  av  a2  s  .  co  m
public void writeBytes(byte[] value, int offset, int length) throws JMSException {
    initializeWriting();
    try {
        this.dataOut.write(value, offset, length);
    } catch (IOException ioe) {
        JMSException jmsEx = new JMSException("Could not write data:" + ioe.getMessage());
        jmsEx.setLinkedException(ioe);
        throw jmsEx;
    }
}

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

/**
 * Reads a <code>boolean</code> from the stream message.
 *
 * @return the <code>boolean</code> value read
 * @throws JMSException//from   ww  w.ja va 2 s .c o  m
 *             if the JMS provider fails to read the message due to some
 *             internal error.
 * @throws MessageEOFException
 *             if unexpected end of message stream has been reached.
 * @throws MessageFormatException
 *             if this type conversion is invalid.
 * @throws javax.jms.MessageNotReadableException
 *             if the message is in write-only mode.
 */
public boolean readBoolean() throws JMSException {
    initializeReading();
    try {

        this.dataIn.mark(10);
        int type = this.dataIn.read();
        if (type == -1) {
            throw new MessageEOFException("reached end of data");
        }
        if (type == MarshallingSupport.BOOLEAN_TYPE) {
            return this.dataIn.readBoolean();
        }
        if (type == MarshallingSupport.STRING_TYPE) {
            return Boolean.valueOf(this.dataIn.readUTF()).booleanValue();
        }
        if (type == MarshallingSupport.NULL) {
            this.dataIn.reset();
            throw new NullPointerException("Cannot convert NULL value to boolean.");
        } else {
            this.dataIn.reset();
            throw new MessageFormatException(" not a boolean type");
        }
    } catch (EOFException e) {
        String exMessage = "Reached premature EOF: " + e.getMessage();
        _log.error(exMessage, e);
        throw new JMSException(exMessage);
    } catch (IOException e) {
        String exMessage = "Could not read boolean: " + e.getMessage();
        _log.error(exMessage, e);
        throw new JMSException(exMessage);
    }
}

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

/**
 * Reads a <code>byte</code> value from the stream message.
 *
 * @return the next byte from the stream message as a 8-bit
 *         <code>byte</code>
 * @throws JMSException/*  w ww.j  a v  a 2  s.  c  o m*/
 *             if the JMS provider fails to read the message due to some
 *             internal error.
 * @throws MessageEOFException
 *             if unexpected end of message stream has been reached.
 * @throws MessageFormatException
 *             if this type conversion is invalid.
 * @throws javax.jms.MessageNotReadableException
 *             if the message is in write-only mode.
 */

public byte readByte() throws JMSException {
    initializeReading();
    try {

        this.dataIn.mark(10);
        int type = this.dataIn.read();
        if (type == -1) {
            throw new MessageEOFException("reached end of data");
        }
        if (type == MarshallingSupport.BYTE_TYPE) {
            return this.dataIn.readByte();
        }
        if (type == MarshallingSupport.STRING_TYPE) {
            return Byte.valueOf(this.dataIn.readUTF()).byteValue();
        }
        if (type == MarshallingSupport.NULL) {
            this.dataIn.reset();
            throw new NullPointerException("Cannot convert NULL value to byte.");
        } else {
            this.dataIn.reset();
            throw new MessageFormatException(" not a byte type");
        }
    } catch (NumberFormatException mfe) {
        try {
            this.dataIn.reset();
        } catch (IOException ioe) {
            JMSException jmsEx = new MessageFormatException(ioe.getMessage());
            jmsEx.setLinkedException(ioe);
            throw jmsEx;
        }
        throw mfe;
    } catch (EOFException e) {
        String exMessage = "Reached premature EOF: " + e.getMessage();
        _log.error(exMessage, e);
        throw new JMSException(exMessage);
    } catch (IOException e) {
        String exMessage = "Could not read boolean: " + e.getMessage();
        _log.error(exMessage, e);
        throw new JMSException(exMessage);
    }
}

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

/**
 * Reads a 16-bit integer from the stream message.
 *
 * @return a 16-bit integer from the stream message
 * @throws JMSException//from  w  w  w.j  a v a 2  s.c o m
 *             if the JMS provider fails to read the message due to some
 *             internal error.
 * @throws MessageEOFException
 *             if unexpected end of message stream has been reached.
 * @throws MessageFormatException
 *             if this type conversion is invalid.
 * @throws MessageNotReadableException
 *             if the message is in write-only mode.
 */

public short readShort() throws JMSException {
    initializeReading();
    try {

        this.dataIn.mark(17);
        int type = this.dataIn.read();
        if (type == -1) {
            throw new MessageEOFException("reached end of data");
        }
        if (type == MarshallingSupport.SHORT_TYPE) {
            return this.dataIn.readShort();
        }
        if (type == MarshallingSupport.BYTE_TYPE) {
            return this.dataIn.readByte();
        }
        if (type == MarshallingSupport.STRING_TYPE) {
            return Short.valueOf(this.dataIn.readUTF()).shortValue();
        }
        if (type == MarshallingSupport.NULL) {
            this.dataIn.reset();
            throw new NullPointerException("Cannot convert NULL value to short.");
        } else {
            this.dataIn.reset();
            throw new MessageFormatException(" not a short type");
        }
    } catch (NumberFormatException mfe) {
        try {
            this.dataIn.reset();
        } catch (IOException ioe) {
            JMSException jmsEx = new MessageFormatException(ioe.getMessage());
            jmsEx.setLinkedException(ioe);
            throw jmsEx;
        }
        throw mfe;

    } catch (EOFException e) {
        String exMessage = "Reached premature EOF: " + e.getMessage();
        _log.error(exMessage, e);
        throw new JMSException(exMessage);
    } catch (IOException e) {
        String exMessage = "Could not read boolean: " + e.getMessage();
        _log.error(exMessage, e);
        throw new JMSException(exMessage);
    }
}

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

/**
 * Reads a Unicode character value from the stream message.
 *
 * @return a Unicode character from the stream message
 * @throws JMSException//from  ww w.  j av  a  2  s. c o m
 *             if the JMS provider fails to read the message due to some
 *             internal error.
 * @throws MessageEOFException
 *             if unexpected end of message stream has been reached.
 * @throws MessageFormatException
 *             if this type conversion is invalid
 * @throws MessageNotReadableException
 *             if the message is in write-only mode.
 */

public char readChar() throws JMSException {
    initializeReading();
    try {

        this.dataIn.mark(17);
        int type = this.dataIn.read();
        if (type == -1) {
            throw new MessageEOFException("reached end of data");
        }
        if (type == MarshallingSupport.CHAR_TYPE) {
            return this.dataIn.readChar();
        }
        if (type == MarshallingSupport.NULL) {
            this.dataIn.reset();
            throw new NullPointerException("Cannot convert NULL value to char.");
        } else {
            this.dataIn.reset();
            throw new MessageFormatException(" not a char type");
        }
    } catch (NumberFormatException mfe) {
        try {
            this.dataIn.reset();
        } catch (IOException ioe) {
            JMSException jmsEx = new MessageFormatException(ioe.getMessage());
            jmsEx.setLinkedException(ioe);
            throw jmsEx;
        }
        throw mfe;

    } catch (EOFException e) {
        String exMessage = "Reached premature EOF: " + e.getMessage();
        _log.error(exMessage, e);
        throw new JMSException(exMessage);
    } catch (IOException e) {
        String exMessage = "Could not read boolean: " + e.getMessage();
        _log.error(exMessage, e);
        throw new JMSException(exMessage);
    }
}