Class ActiveMQStreamMessage

    • Method Detail

      • readBytes

        public int readBytes​(byte[] value)
                      throws JMSException
        Description copied from interface: StreamMessage
        Reads a byte array field from the stream message into the specified byte[] object (the read buffer).

        To read the field value, readBytes should be successively called until it returns a value less than the length of the read buffer. The value of the bytes in the buffer following the last byte read is undefined.

        If readBytes returns a value equal to the length of the buffer, a subsequent readBytes call must be made. If there are no more bytes to be read, this call returns -1.

        If the byte array field value is null, readBytes returns -1.

        If the byte array field value is empty, readBytes returns 0.

        Once the first readBytes call on a byte[] field value has been made, the full value of the field must be read before it is valid to read the next field. An attempt to read the next field before that has been done will throw a MessageFormatException.

        To read the byte field value into a new byte[] object, use the readObject method.

        Specified by:
        readBytes in interface StreamMessage
        Parameters:
        value - the buffer into which the data is read
        Returns:
        the total number of bytes read into the buffer, or -1 if there is no more data because the end of the byte field has been reached
        Throws:
        JMSException - if the Jakarta Messaging provider fails to read the message due to some internal error.
        MessageEOFException - if unexpected end of message stream has been reached.
        MessageFormatException - if this type conversion is invalid.
        MessageNotReadableException - if the message is in write-only mode.
        See Also:
        StreamMessage.readObject()
      • readObject

        public Object readObject()
                          throws JMSException
        Description copied from interface: StreamMessage
        Reads an object from the stream message.

        This method can be used to return, in objectified format, an object in the Java programming language ("Java object") that has been written to the stream with the equivalent writeObject method call, or its equivalent primitive writetype method.

        Note that byte values are returned as byte[], not Byte[].

        An attempt to call readObject to read a byte field value into a new byte[] object before the full value of the byte field has been read will throw a MessageFormatException.

        Specified by:
        readObject in interface StreamMessage
        Returns:
        a Java object from the stream message, in objectified format (for example, if the object was written as an int, an Integer is returned)
        Throws:
        JMSException - if the Jakarta Messaging provider fails to read the message due to some internal error.
        MessageEOFException - if unexpected end of message stream has been reached.
        MessageFormatException - if this type conversion is invalid.
        MessageNotReadableException - if the message is in write-only mode.
        See Also:
        StreamMessage.readBytes(byte[] value)
      • writeBoolean

        public void writeBoolean​(boolean value)
                          throws JMSException
        Description copied from interface: StreamMessage
        Writes a boolean to the stream message. The value true is written as the value (byte)1; the value false is written as the value (byte)0.
        Specified by:
        writeBoolean in interface StreamMessage
        Parameters:
        value - the boolean value to be written
        Throws:
        JMSException - if the Jakarta Messaging provider fails to write the message due to some internal error.
        MessageNotWriteableException - if the message is in read-only mode.
      • writeByte

        public void writeByte​(byte value)
                       throws JMSException
        Description copied from interface: StreamMessage
        Writes a byte to the stream message.
        Specified by:
        writeByte in interface StreamMessage
        Parameters:
        value - the byte value to be written
        Throws:
        JMSException - if the Jakarta Messaging provider fails to write the message due to some internal error.
        MessageNotWriteableException - if the message is in read-only mode.
      • writeShort

        public void writeShort​(short value)
                        throws JMSException
        Description copied from interface: StreamMessage
        Writes a short to the stream message.
        Specified by:
        writeShort in interface StreamMessage
        Parameters:
        value - the short value to be written
        Throws:
        JMSException - if the Jakarta Messaging provider fails to write the message due to some internal error.
        MessageNotWriteableException - if the message is in read-only mode.
      • writeChar

        public void writeChar​(char value)
                       throws JMSException
        Description copied from interface: StreamMessage
        Writes a char to the stream message.
        Specified by:
        writeChar in interface StreamMessage
        Parameters:
        value - the char value to be written
        Throws:
        JMSException - if the Jakarta Messaging provider fails to write the message due to some internal error.
        MessageNotWriteableException - if the message is in read-only mode.
      • writeInt

        public void writeInt​(int value)
                      throws JMSException
        Description copied from interface: StreamMessage
        Writes an int to the stream message.
        Specified by:
        writeInt in interface StreamMessage
        Parameters:
        value - the int value to be written
        Throws:
        JMSException - if the Jakarta Messaging provider fails to write the message due to some internal error.
        MessageNotWriteableException - if the message is in read-only mode.
      • writeLong

        public void writeLong​(long value)
                       throws JMSException
        Description copied from interface: StreamMessage
        Writes a long to the stream message.
        Specified by:
        writeLong in interface StreamMessage
        Parameters:
        value - the long value to be written
        Throws:
        JMSException - if the Jakarta Messaging provider fails to write the message due to some internal error.
        MessageNotWriteableException - if the message is in read-only mode.
      • writeFloat

        public void writeFloat​(float value)
                        throws JMSException
        Description copied from interface: StreamMessage
        Writes a float to the stream message.
        Specified by:
        writeFloat in interface StreamMessage
        Parameters:
        value - the float value to be written
        Throws:
        JMSException - if the Jakarta Messaging provider fails to write the message due to some internal error.
        MessageNotWriteableException - if the message is in read-only mode.
      • writeDouble

        public void writeDouble​(double value)
                         throws JMSException
        Description copied from interface: StreamMessage
        Writes a double to the stream message.
        Specified by:
        writeDouble in interface StreamMessage
        Parameters:
        value - the double value to be written
        Throws:
        JMSException - if the Jakarta Messaging provider fails to write the message due to some internal error.
        MessageNotWriteableException - if the message is in read-only mode.
      • writeBytes

        public void writeBytes​(byte[] value)
                        throws JMSException
        Description copied from interface: StreamMessage
        Writes a byte array field to the stream message.

        The byte array value is written to the message as a byte array field. Consecutively written byte array fields are treated as two distinct fields when the fields are read.

        Specified by:
        writeBytes in interface StreamMessage
        Parameters:
        value - the byte array value to be written
        Throws:
        JMSException - if the Jakarta Messaging provider fails to write the message due to some internal error.
        MessageNotWriteableException - if the message is in read-only mode.
      • writeBytes

        public void writeBytes​(byte[] value,
                               int offset,
                               int length)
                        throws JMSException
        Description copied from interface: StreamMessage
        Writes a portion of a byte array as a byte array field to the stream message.

        The a portion of the byte array value is written to the message as a byte array field. Consecutively written byte array fields are treated as two distinct fields when the fields are read.

        Specified by:
        writeBytes in interface StreamMessage
        Parameters:
        value - the byte array value to be written
        offset - the initial offset within the byte array
        length - the number of bytes to use
        Throws:
        JMSException - if the Jakarta Messaging provider fails to write the message due to some internal error.
        MessageNotWriteableException - if the message is in read-only mode.
      • writeObject

        public void writeObject​(Object value)
                         throws JMSException
        Description copied from interface: StreamMessage
        Writes an object to the stream message.

        This method works only for the objectified primitive object types (Integer, Double, Long ...), String objects, and byte arrays.

        Specified by:
        writeObject in interface StreamMessage
        Parameters:
        value - the Java object to be written
        Throws:
        JMSException - if the Jakarta Messaging provider fails to write the message due to some internal error.
        MessageFormatException - if the object is invalid.
        MessageNotWriteableException - if the message is in read-only mode.
      • reset

        public void reset()
                   throws JMSException
        Description copied from interface: StreamMessage
        Puts the message body in read-only mode and repositions the stream to the beginning.
        Specified by:
        reset in interface StreamMessage
        Throws:
        JMSException - if the Jakarta Messaging provider fails to reset the message due to some internal error.
        MessageFormatException - if the message has an invalid format.
      • clearBody

        public void clearBody()
                       throws JMSException
        Description copied from interface: Message
        Clears out the message body. Clearing a message's body does not clear its header values or property entries.

        If this message body was read-only, calling this method leaves the message body in the same state as an empty body in a newly created message.

        Specified by:
        clearBody in interface Message
        Overrides:
        clearBody in class ActiveMQMessage
        Throws:
        JMSException - if the Jakarta Messaging provider fails to clear the message body due to some internal error.
      • isBodyAssignableTo

        public boolean isBodyAssignableTo​(Class c)
        Description copied from interface: Message
        Returns whether the message body is capable of being assigned to the specified type. If this method returns true then a subsequent call to the method getBody on the same message with the same type argument would not throw a MessageFormatException.

        If the message is a StreamMessage then false is always returned. If the message is a ObjectMessage and object deserialization fails then false is returned. If the message has no body then any type may be specified and true is returned.

        Specified by:
        isBodyAssignableTo in interface Message
        Overrides:
        isBodyAssignableTo in class ActiveMQMessage
        Parameters:
        c - The specified type
        If the message is a TextMessage then this method will only return true if this parameter is set to String.class or another type to which a String is assignable.
        If the message is a ObjectMessage then this method will only return true if this parameter is set to java.io.Serializable.class or another class to which the body is assignable.
        If the message is a MapMessage then this method will only return true if this parameter is set to java.util.Map.class (or java.lang.Object.class).
        If the message is a BytesMessage then this this method will only return true if this parameter is set to byte[].class (or java.lang.Object.class).
        If the message is a TextMessage, ObjectMessage, MapMessage or BytesMessage and the message has no body, then the above does not apply and this method will return true irrespective of the value of this parameter.
        If the message is a Message (but not one of its subtypes) then this method will return true irrespective of the value of this parameter.
        Returns:
        whether the message body is capable of being assigned to the specified type