activemq-cpp-3.6.0
cms::BytesMessage Class Reference

A BytesMessage object is used to send a message containing a stream of unsigned bytes. More...

#include <src/main/cms/BytesMessage.h>

Inheritance diagram for cms::BytesMessage:

Public Member Functions

virtual ~BytesMessage ()
virtual void setBodyBytes (const unsigned char *buffer, int numBytes)=0
 sets the bytes given to the message body.
virtual unsigned char * getBodyBytes () const =0
 Gets the bytes that are contained in this message and returns them in a newly allocated array that becomes the property of the caller.
virtual int getBodyLength () const =0
 Returns the number of bytes contained in the body of this message.
virtual void reset ()=0
 Puts the message body in read-only mode and repositions the stream of bytes to the beginning.
virtual bool readBoolean () const =0
 Reads a Boolean from the Bytes message stream.
virtual void writeBoolean (bool value)=0
 Writes a boolean to the bytes message stream as a 1-byte value.
virtual unsigned char readByte () const =0
 Reads a Byte from the Bytes message stream.
virtual void writeByte (unsigned char value)=0
 Writes a byte to the bytes message stream as a 1-byte value.
virtual int readBytes (std::vector< unsigned char > &value) const =0
 Reads a byte array from the bytes message stream.
virtual void writeBytes (const std::vector< unsigned char > &value)=0
 Writes a byte array to the bytes message stream using the vector size as the number of bytes to write.
virtual int readBytes (unsigned char *buffer, int length) const =0
 Reads a portion of the bytes message stream.
virtual void writeBytes (const unsigned char *value, int offset, int length)=0
 Writes a portion of a byte array to the bytes message stream.
virtual char readChar () const =0
 Reads a Char from the Bytes message stream.
virtual void writeChar (char value)=0
 Writes a char to the bytes message stream as a 1-byte value.
virtual float readFloat () const =0
 Reads a 32 bit float from the Bytes message stream.
virtual void writeFloat (float value)=0
 Writes a float to the bytes message stream as a 4 byte value.
virtual double readDouble () const =0
 Reads a 64 bit double from the Bytes message stream.
virtual void writeDouble (double value)=0
 Writes a double to the bytes message stream as a 8 byte value.
virtual short readShort () const =0
 Reads a 16 bit signed short from the Bytes message stream.
virtual void writeShort (short value)=0
 Writes a signed short to the bytes message stream as a 2 byte value.
virtual unsigned short readUnsignedShort () const =0
 Reads a 16 bit unsigned short from the Bytes message stream.
virtual void writeUnsignedShort (unsigned short value)=0
 Writes a unsigned short to the bytes message stream as a 2 byte value.
virtual int readInt () const =0
 Reads a 32 bit signed integer from the Bytes message stream.
virtual void writeInt (int value)=0
 Writes a signed int to the bytes message stream as a 4 byte value.
virtual long long readLong () const =0
 Reads a 64 bit long from the Bytes message stream.
virtual void writeLong (long long value)=0
 Writes a long long to the bytes message stream as a 8 byte value.
virtual std::string readString () const =0
 Reads an ASCII String from the Bytes message stream.
virtual void writeString (const std::string &value)=0
 Writes an ASCII String to the Bytes message stream.
virtual std::string readUTF () const =0
 Reads an UTF String from the BytesMessage stream.
virtual void writeUTF (const std::string &value)=0
 Writes an UTF String to the BytesMessage stream.
virtual BytesMessageclone () const =0
 Clones this message.
- Public Member Functions inherited from cms::Message
virtual ~Message ()
virtual void acknowledge () const =0
 Acknowledges all consumed messages of the session of this consumed message.
virtual void clearBody ()=0
 Clears out the body of the message.
virtual void clearProperties ()=0
 Clears out the message body.
virtual std::vector< std::string > getPropertyNames () const =0
 Retrieves the property names.
virtual bool propertyExists (const std::string &name) const =0
 Indicates whether or not a given property exists.
virtual ValueType getPropertyValueType (const std::string &name) const =0
 Returns the value type for the given property key.
virtual bool getBooleanProperty (const std::string &name) const =0
 Gets a boolean property.
virtual unsigned char getByteProperty (const std::string &name) const =0
 Gets a byte property.
virtual double getDoubleProperty (const std::string &name) const =0
 Gets a double property.
virtual float getFloatProperty (const std::string &name) const =0
 Gets a float property.
virtual int getIntProperty (const std::string &name) const =0
 Gets a int property.
virtual long long getLongProperty (const std::string &name) const =0
 Gets a long property.
virtual short getShortProperty (const std::string &name) const =0
 Gets a short property.
virtual std::string getStringProperty (const std::string &name) const =0
 Gets a string property.
virtual void setBooleanProperty (const std::string &name, bool value)=0
 Sets a boolean property.
virtual void setByteProperty (const std::string &name, unsigned char value)=0
 Sets a byte property.
virtual void setDoubleProperty (const std::string &name, double value)=0
 Sets a double property.
virtual void setFloatProperty (const std::string &name, float value)=0
 Sets a float property.
virtual void setIntProperty (const std::string &name, int value)=0
 Sets a int property.
virtual void setLongProperty (const std::string &name, long long value)=0
 Sets a long property.
virtual void setShortProperty (const std::string &name, short value)=0
 Sets a short property.
virtual void setStringProperty (const std::string &name, const std::string &value)=0
 Sets a string property.
virtual std::string getCMSCorrelationID () const =0
 Gets the correlation ID for the message.
virtual void setCMSCorrelationID (const std::string &correlationId)=0
 Sets the correlation ID for the message.
virtual int getCMSDeliveryMode () const =0
 Gets the DeliveryMode for this message.
virtual void setCMSDeliveryMode (int mode)=0
 Sets the DeliveryMode for this message.
virtual const DestinationgetCMSDestination () const =0
 Gets the Destination object for this message.
virtual void setCMSDestination (const Destination *destination)=0
 Sets the Destination object for this message.
virtual long long getCMSExpiration () const =0
 Gets the message's expiration value.
virtual void setCMSExpiration (long long expireTime)=0
 Sets the message's expiration value.
virtual std::string getCMSMessageID () const =0
 The CMSMessageID header field contains a value that uniquely identifies each message sent by a provider.
virtual void setCMSMessageID (const std::string &id)=0
 Sets the message ID.
virtual int getCMSPriority () const =0
 Gets the message priority level.
virtual void setCMSPriority (int priority)=0
 Sets the Priority Value for this message.
virtual bool getCMSRedelivered () const =0
 Gets an indication of whether this message is being redelivered.
virtual void setCMSRedelivered (bool redelivered)=0
 Specifies whether this message is being redelivered.
virtual const cms::DestinationgetCMSReplyTo () const =0
 Gets the Destination object to which a reply to this message should be sent.
virtual void setCMSReplyTo (const cms::Destination *destination)=0
 Sets the Destination object to which a reply to this message should be sent.
virtual long long getCMSTimestamp () const =0
 Gets the message timestamp.
virtual void setCMSTimestamp (long long timeStamp)=0
 Sets the message timestamp.
virtual std::string getCMSType () const =0
 Gets the message type identifier supplied by the client when the message was sent.
virtual void setCMSType (const std::string &type)=0
 Sets the message type.

Additional Inherited Members

- Public Types inherited from cms::Message
enum  ValueType {
  NULL_TYPE = 0, BOOLEAN_TYPE = 1, BYTE_TYPE = 2, CHAR_TYPE = 3,
  SHORT_TYPE = 4, INTEGER_TYPE = 5, LONG_TYPE = 6, DOUBLE_TYPE = 7,
  FLOAT_TYPE = 8, STRING_TYPE = 9, BYTE_ARRAY_TYPE = 10, UNKNOWN_TYPE = 11
}
 Defines the Type Identifiers used to identify the type contained within a specific Message property or MapMessage keyed value. More...
- Static Public Attributes inherited from cms::Message
static const int DEFAULT_DELIVERY_MODE
 The Default delivery mode for Message Producers is PERSISTENT.
static const int DEFAULT_MSG_PRIORITY
 The Default priority assigned to a Message is 4.
static const long long DEFAULT_TIME_TO_LIVE
 The Default Time to Live for a Message Producer is unlimited, the message will never expire.

Detailed Description

A BytesMessage object is used to send a message containing a stream of unsigned bytes.

It inherits from the Message interface and adds a bytes message body. The receiver of the message supplies the interpretation of the bytes using the methods added by the BytesMessage interface.

The BytesMessage methods are based largely on those found in decaf.io.DataInputStream and decaf.io.DataOutputStream.

Although the CMS API allows the use of message properties with byte messages, they are typically not used, since the inclusion of properties may affect the format.

The primitive types can be written explicitly using methods for each type. Because the C++ language is more limited when dealing with primitive types the JMS equivalent generic read and write methods that take Java objects cannot be provided in the CMS API.

When the message is first created, and when clearBody is called, the body of the message is in write-only mode. After the first call to reset has been made, the message body is in read-only mode. After a message has been sent, the client that sent it can retain and modify it without affecting the message that has been sent. The same message object can be sent multiple times. When a message has been received, the provider has called reset so that the message body is in read-only mode for the client.

If clearBody is called on a message in read-only mode, the message body is cleared and the message is in write-only mode.

If a client attempts to read a message in write-only mode, a MessageNotReadableException is thrown.

If a client attempts to write a message in read-only mode, a MessageNotWriteableException is thrown.

Since
1.0

Constructor & Destructor Documentation

virtual cms::BytesMessage::~BytesMessage ( )
virtual

Member Function Documentation

virtual BytesMessage* cms::BytesMessage::clone ( ) const
pure virtual

Clones this message.

Returns
a deep copy of this message.
Exceptions
CMSException- if an internal error occurs while cloning the Message.

Implements cms::Message.

Implemented in activemq::commands::ActiveMQBytesMessage.

virtual unsigned char* cms::BytesMessage::getBodyBytes ( ) const
pure virtual

Gets the bytes that are contained in this message and returns them in a newly allocated array that becomes the property of the caller.

This is a copy of the data contained in this message, changing the value contained in this array has no effect on the data contained in this message.

Returns
pointer to a byte buffer that the call owns upon completion of this method.
Exceptions
CMSException- If an internal error occurs.
MessageNotReadableException- If the message is in Write Only Mode.

Implemented in activemq::commands::ActiveMQBytesMessage.

virtual int cms::BytesMessage::getBodyLength ( ) const
pure virtual

Returns the number of bytes contained in the body of this message.

Returns
number of bytes.
Exceptions
CMSException- If an internal error occurs.
MessageNotReadableException- If the message is in Write Only Mode.

Implemented in activemq::commands::ActiveMQBytesMessage.

virtual bool cms::BytesMessage::readBoolean ( ) const
pure virtual

Reads a Boolean from the Bytes message stream.

Returns
boolean value from stream
Exceptions
CMSException- if the CMS provider fails to read the message due to some internal error.
MessageEOFException- if unexpected end of bytes stream has been reached.
MessageNotReadableException- if the message is in write-only mode.

Implemented in activemq::commands::ActiveMQBytesMessage.

virtual unsigned char cms::BytesMessage::readByte ( ) const
pure virtual

Reads a Byte from the Bytes message stream.

Returns
unsigned char value from stream
Exceptions
CMSException- if the CMS provider fails to read the message due to some internal error.
MessageEOFException- if unexpected end of bytes stream has been reached.
MessageNotReadableException- if the message is in write-only mode.

Implemented in activemq::commands::ActiveMQBytesMessage.

virtual int cms::BytesMessage::readBytes ( std::vector< unsigned char > &  value) const
pure virtual

Reads a byte array from the bytes message stream.

If the length of vector value is less than the number of bytes remaining to be read from the stream, the vector should be filled. A subsequent call reads the next increment, and so on.

If the number of bytes remaining in the stream is less than the length of vector value, the bytes should be read into the vector. The return value of the total number of bytes read will be less than the length of the vector, indicating that there are no more bytes left to be read from the stream. The next read of the stream returns -1.

Parameters
valuebuffer to place data in
Returns
the total number of bytes read into the buffer, or -1 if there is no more data because the end of the stream has been reached
Exceptions
CMSException- if the CMS provider fails to read the message due to some internal error.
MessageEOFException- if unexpected end of bytes stream has been reached.
MessageNotReadableException- if the message is in write-only mode.

Implemented in activemq::commands::ActiveMQBytesMessage.

virtual int cms::BytesMessage::readBytes ( unsigned char *  buffer,
int  length 
) const
pure virtual

Reads a portion of the bytes message stream.

If the length of array value is less than the number of bytes remaining to be read from the stream, the array should be filled. A subsequent call reads the next increment, and so on.

If the number of bytes remaining in the stream is less than the length of array value, the bytes should be read into the array. The return value of the total number of bytes read will be less than the length of the array, indicating that there are no more bytes left to be read from the stream. The next read of the stream returns -1.

If length is negative, or length is greater than the length of the array value, then an IndexOutOfBoundsException is thrown. No bytes will be read from the stream for this exception case.

Parameters
bufferthe buffer into which the data is read
lengththe number of bytes to read; must be less than or equal to value.length
Returns
the total number of bytes read into the buffer, or -1 if there is no more data because the end of the stream has been reached
Exceptions
CMSException- if the CMS provider fails to read the message due to some internal error.
MessageEOFException- if unexpected end of bytes stream has been reached.
MessageNotReadableException- if the message is in write-only mode.

Implemented in activemq::commands::ActiveMQBytesMessage.

virtual char cms::BytesMessage::readChar ( ) const
pure virtual

Reads a Char from the Bytes message stream.

Returns
char value from stream
Exceptions
CMSException- if the CMS provider fails to read the message due to some internal error.
MessageEOFException- if unexpected end of bytes stream has been reached.
MessageNotReadableException- if the message is in write-only mode.

Implemented in activemq::commands::ActiveMQBytesMessage.

virtual double cms::BytesMessage::readDouble ( ) const
pure virtual

Reads a 64 bit double from the Bytes message stream.

Returns
double value from stream
Exceptions
CMSException- if the CMS provider fails to read the message due to some internal error.
MessageEOFException- if unexpected end of bytes stream has been reached.
MessageNotReadableException- if the message is in write-only mode.

Implemented in activemq::commands::ActiveMQBytesMessage.

virtual float cms::BytesMessage::readFloat ( ) const
pure virtual

Reads a 32 bit float from the Bytes message stream.

Returns
double value from stream
Exceptions
CMSException- if the CMS provider fails to read the message due to some internal error.
MessageEOFException- if unexpected end of bytes stream has been reached.
MessageNotReadableException- if the message is in write-only mode.

Implemented in activemq::commands::ActiveMQBytesMessage.

virtual int cms::BytesMessage::readInt ( ) const
pure virtual

Reads a 32 bit signed integer from the Bytes message stream.

Returns
int value from stream
Exceptions
CMSException- if the CMS provider fails to read the message due to some internal error.
MessageEOFException- if unexpected end of bytes stream has been reached.
MessageNotReadableException- if the message is in write-only mode.

Implemented in activemq::commands::ActiveMQBytesMessage.

virtual long long cms::BytesMessage::readLong ( ) const
pure virtual

Reads a 64 bit long from the Bytes message stream.

Returns
long long value from stream
Exceptions
CMSException- if the CMS provider fails to read the message due to some internal error.
MessageEOFException- if unexpected end of bytes stream has been reached.
MessageNotReadableException- if the message is in write-only mode.

Implemented in activemq::commands::ActiveMQBytesMessage.

virtual short cms::BytesMessage::readShort ( ) const
pure virtual

Reads a 16 bit signed short from the Bytes message stream.

Returns
short value from stream
Exceptions
CMSException- if the CMS provider fails to read the message due to some internal error.
MessageEOFException- if unexpected end of bytes stream has been reached.
MessageNotReadableException- if the message is in write-only mode.

Implemented in activemq::commands::ActiveMQBytesMessage.

virtual std::string cms::BytesMessage::readString ( ) const
pure virtual

Reads an ASCII String from the Bytes message stream.

Returns
String from stream
Exceptions
CMSException- if the CMS provider fails to read the message due to some internal error.
MessageEOFException- if unexpected end of bytes stream has been reached.
MessageNotReadableException- if the message is in write-only mode.

Implemented in activemq::commands::ActiveMQBytesMessage.

virtual unsigned short cms::BytesMessage::readUnsignedShort ( ) const
pure virtual

Reads a 16 bit unsigned short from the Bytes message stream.

Returns
unsigned short value from stream
Exceptions
CMSException- if the CMS provider fails to read the message due to some internal error.
MessageEOFException- if unexpected end of bytes stream has been reached.
MessageNotReadableException- if the message is in write-only mode.

Implemented in activemq::commands::ActiveMQBytesMessage.

virtual std::string cms::BytesMessage::readUTF ( ) const
pure virtual

Reads an UTF String from the BytesMessage stream.

Returns
String from stream
Exceptions
CMSException- if the CMS provider fails to read the message due to some internal error.
MessageEOFException- if unexpected end of bytes stream has been reached.
MessageNotReadableException- if the message is in write-only mode.

Implemented in activemq::commands::ActiveMQBytesMessage.

virtual void cms::BytesMessage::reset ( )
pure virtual

Puts the message body in read-only mode and repositions the stream of bytes to the beginning.

Exceptions
CMSException- If the provider fails to perform the reset operation.
MessageFormatException- If the Message has an invalid format.

Implemented in activemq::commands::ActiveMQBytesMessage.

virtual void cms::BytesMessage::setBodyBytes ( const unsigned char *  buffer,
int  numBytes 
)
pure virtual

sets the bytes given to the message body.

Parameters
bufferByte Buffer to copy
numBytesNumber of bytes in Buffer to copy
Exceptions
CMSException- If an internal error occurs.
MessageNotWriteableException- if in Read Only Mode.

Implemented in activemq::commands::ActiveMQBytesMessage.

virtual void cms::BytesMessage::writeBoolean ( bool  value)
pure virtual

Writes a boolean to the bytes message stream as a 1-byte value.

The value true is written as the value (byte)1; the value false is written as the value (byte)0.

Parameters
valueboolean to write to the stream
Exceptions
CMSException- if the CMS provider fails to write the message due to some internal error.
MessageNotWriteableException- if the message is in read-only mode.

Implemented in activemq::commands::ActiveMQBytesMessage.

virtual void cms::BytesMessage::writeByte ( unsigned char  value)
pure virtual

Writes a byte to the bytes message stream as a 1-byte value.

Parameters
valuebyte to write to the stream
Exceptions
CMSException- if the CMS provider fails to write the message due to some internal error.
MessageNotWriteableException- if the message is in read-only mode.

Implemented in activemq::commands::ActiveMQBytesMessage.

virtual void cms::BytesMessage::writeBytes ( const std::vector< unsigned char > &  value)
pure virtual

Writes a byte array to the bytes message stream using the vector size as the number of bytes to write.

Parameters
valuebytes to write to the stream
Exceptions
CMSException- if the CMS provider fails to write the message due to some internal error.
MessageNotWriteableException- if the message is in read-only mode.

Implemented in activemq::commands::ActiveMQBytesMessage.

virtual void cms::BytesMessage::writeBytes ( const unsigned char *  value,
int  offset,
int  length 
)
pure virtual

Writes a portion of a byte array to the bytes message stream.

size as the number of bytes to write.

Parameters
valuebytes to write to the stream
offsetthe initial offset within the byte array
lengththe number of bytes to use
Exceptions
CMSException- if the CMS provider fails to write the message due to some internal error.
MessageNotWriteableException- if the message is in read-only mode.

Implemented in activemq::commands::ActiveMQBytesMessage.

virtual void cms::BytesMessage::writeChar ( char  value)
pure virtual

Writes a char to the bytes message stream as a 1-byte value.

Parameters
valuechar to write to the stream
Exceptions
CMSException- if the CMS provider fails to write the message due to some internal error.
MessageNotWriteableException- if the message is in read-only mode.

Implemented in activemq::commands::ActiveMQBytesMessage.

virtual void cms::BytesMessage::writeDouble ( double  value)
pure virtual

Writes a double to the bytes message stream as a 8 byte value.

Parameters
valuedouble to write to the stream
Exceptions
CMSException- if the CMS provider fails to write the message due to some internal error.
MessageNotWriteableException- if the message is in read-only mode.

Implemented in activemq::commands::ActiveMQBytesMessage.

virtual void cms::BytesMessage::writeFloat ( float  value)
pure virtual

Writes a float to the bytes message stream as a 4 byte value.

Parameters
valuefloat to write to the stream
Exceptions
CMSException- if the CMS provider fails to write the message due to some internal error.
MessageNotWriteableException- if the message is in read-only mode.

Implemented in activemq::commands::ActiveMQBytesMessage.

virtual void cms::BytesMessage::writeInt ( int  value)
pure virtual

Writes a signed int to the bytes message stream as a 4 byte value.

Parameters
valuesigned int to write to the stream
Exceptions
CMSException- if the CMS provider fails to write the message due to some internal error.
MessageNotWriteableException- if the message is in read-only mode.

Implemented in activemq::commands::ActiveMQBytesMessage.

virtual void cms::BytesMessage::writeLong ( long long  value)
pure virtual

Writes a long long to the bytes message stream as a 8 byte value.

Parameters
valuesigned long long to write to the stream
Exceptions
CMSException- if the CMS provider fails to write the message due to some internal error.
MessageNotWriteableException- if the message is in read-only mode.

Implemented in activemq::commands::ActiveMQBytesMessage.

virtual void cms::BytesMessage::writeShort ( short  value)
pure virtual

Writes a signed short to the bytes message stream as a 2 byte value.

Parameters
valuesigned short to write to the stream
Exceptions
CMSException- if the CMS provider fails to write the message due to some internal error.
MessageNotWriteableException- if the message is in read-only mode.

Implemented in activemq::commands::ActiveMQBytesMessage.

virtual void cms::BytesMessage::writeString ( const std::string &  value)
pure virtual

Writes an ASCII String to the Bytes message stream.

Parameters
valueString to write to the stream
Exceptions
CMSException- if the CMS provider fails to write the message due to some internal error.
MessageNotWriteableException- if the message is in read-only mode.

Implemented in activemq::commands::ActiveMQBytesMessage.

virtual void cms::BytesMessage::writeUnsignedShort ( unsigned short  value)
pure virtual

Writes a unsigned short to the bytes message stream as a 2 byte value.

Parameters
valueunsigned short to write to the stream
Exceptions
CMSException- if the CMS provider fails to write the message due to some internal error.
MessageNotWriteableException- if the message is in read-only mode.

Implemented in activemq::commands::ActiveMQBytesMessage.

virtual void cms::BytesMessage::writeUTF ( const std::string &  value)
pure virtual

Writes an UTF String to the BytesMessage stream.

Parameters
valueString to write to the stream
Exceptions
CMSException- if the CMS provider fails to read the message due to some internal error.
MessageNotWriteableException- if the message is in read-only mode.

Implemented in activemq::commands::ActiveMQBytesMessage.


The documentation for this class was generated from the following file: