Interface IStreamMessage
A StreamMessage object is used to send a stream of primitive types in the .NET programming language. It is filled and read sequentially. It inherits from the Message interface and adds a stream message body.
The primitive types can be read or written explicitly using methods for each type. They may also be read or written generically as objects. For instance, a call to IStreamMessage.WriteInt32(6) is equivalent to StreamMessage.WriteObject( (Int32)6 ). Both forms are provided, because the explicit form is convenient for static programming, and the object form is needed when types are not known at compile time.
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 body 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.
IStreamMessage objects support the following conversion table. The marked cases must be supported. The unmarked cases must throw a NMSException. The String-to-primitive conversions may throw a runtime exception if the primitive's valueOf() method does not accept it as a valid String representation of the primitive.
A value written as the row type can be read as the column type.
boolean byte short char int long float double String byte[] | |
---|---|
boolean | X X |
byte | X X X X X |
short | X X X X |
char | X X |
int | X X X |
long | X X |
float | X X X |
double | X X |
String | X X X X X X X X |
byte[] | X |
---------------------------------------------------------------------- |
Inherited Members
Namespace: Apache.NMS
Assembly: Apache.NMS.dll
Syntax
public interface IStreamMessage : IMessage
Methods
| Improve this Doc View SourceReadBoolean()
Reads a boolean from the stream message.
Declaration
bool ReadBoolean()
Returns
Type | Description |
---|---|
System.Boolean | A System.Boolean |
Exceptions
Type | Condition |
---|---|
NMSException | if the NMS 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. |
ReadByte()
Reads a byte from the stream message.
Declaration
byte ReadByte()
Returns
Type | Description |
---|---|
System.Byte | A System.Byte |
Exceptions
Type | Condition |
---|---|
NMSException | if the NMS 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. |
ReadBytes(Byte[])
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.
Declaration
int ReadBytes(byte[] value)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | value | A System.Byte |
Returns
Type | Description |
---|---|
System.Int32 | A System.Byte 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 |
Exceptions
Type | Condition |
---|---|
NMSException | if the NMS 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
| Improve this Doc View SourceReadChar()
Reads a char from the stream message.
Declaration
char ReadChar()
Returns
Type | Description |
---|---|
System.Char | A System.Char |
Exceptions
Type | Condition |
---|---|
NMSException | if the NMS 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. |
ReadDouble()
Reads a double from the stream message.
Declaration
double ReadDouble()
Returns
Type | Description |
---|---|
System.Double | A System.Double |
Exceptions
Type | Condition |
---|---|
NMSException | if the NMS 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. |
ReadInt16()
Reads a short from the stream message.
Declaration
short ReadInt16()
Returns
Type | Description |
---|---|
System.Int16 | A System.Int16 |
Exceptions
Type | Condition |
---|---|
NMSException | if the NMS 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. |
ReadInt32()
Reads a int from the stream message.
Declaration
int ReadInt32()
Returns
Type | Description |
---|---|
System.Int32 | A System.Int32 |
Exceptions
Type | Condition |
---|---|
NMSException | if the NMS 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. |
ReadInt64()
Reads a long from the stream message.
Declaration
long ReadInt64()
Returns
Type | Description |
---|---|
System.Int64 | A System.Int64 |
Exceptions
Type | Condition |
---|---|
NMSException | if the NMS 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. |
ReadObject()
Reads a Object from the stream message.
Declaration
object ReadObject()
Returns
Type | Description |
---|---|
System.Object | A System.Object |
Exceptions
Type | Condition |
---|---|
NMSException | if the NMS 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. |
ReadSingle()
Reads a float from the stream message.
Declaration
float ReadSingle()
Returns
Type | Description |
---|---|
System.Single | A System.Single |
Exceptions
Type | Condition |
---|---|
NMSException | if the NMS 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. |
ReadString()
Reads a string from the stream message.
Declaration
string ReadString()
Returns
Type | Description |
---|---|
System.String | A System.String |
Exceptions
Type | Condition |
---|---|
NMSException | if the NMS 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. |
Reset()
Puts the message body in read-only mode and repositions the stream to the beginning.
Declaration
void Reset()
Exceptions
Type | Condition |
---|---|
MessageFormatException | Thrown when the Message has an invalid format. |
NMSException | Thrown when there is an unhandled exception thrown from the provider. |
WriteBoolean(Boolean)
Writes a boolean to the stream message.
Declaration
void WriteBoolean(bool value)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | value | A System.Boolean |
Exceptions
Type | Condition |
---|---|
NMSException | if the NMS provider fails to write to the message due to some internal error. |
MessageNotWriteableException | if the message is in read-only mode. |
WriteByte(Byte)
Writes a byte to the stream message.
Declaration
void WriteByte(byte value)
Parameters
Type | Name | Description |
---|---|---|
System.Byte | value | A System.Byte |
Exceptions
Type | Condition |
---|---|
NMSException | if the NMS provider fails to write to the message due to some internal error. |
MessageNotWriteableException | if the message is in read-only mode. |
WriteBytes(Byte[])
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.
Declaration
void WriteBytes(byte[] value)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | value | A System.Byte |
Exceptions
Type | Condition |
---|---|
NMSException | if the NMS provider fails to write to the message due to some internal error. |
MessageNotWriteableException | if the message is in read-only mode. |
WriteBytes(Byte[], Int32, Int32)
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.
Declaration
void WriteBytes(byte[] value, int offset, int length)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | value | A System.Byte |
System.Int32 | offset | A System.Int32 value that indicates the point in the buffer to begin writing to the stream message. |
System.Int32 | length | A System.Int32 value that indicates how many bytes in the buffer to write to the stream message. |
Exceptions
Type | Condition |
---|---|
NMSException | if the NMS provider fails to write to the message due to some internal error. |
MessageNotWriteableException | if the message is in read-only mode. |
WriteChar(Char)
Writes a char to the stream message.
Declaration
void WriteChar(char value)
Parameters
Type | Name | Description |
---|---|---|
System.Char | value | A System.Char |
Exceptions
Type | Condition |
---|---|
NMSException | if the NMS provider fails to write to the message due to some internal error. |
MessageNotWriteableException | if the message is in read-only mode. |
WriteDouble(Double)
Writes a double to the stream message.
Declaration
void WriteDouble(double value)
Parameters
Type | Name | Description |
---|---|---|
System.Double | value | A System.Double |
Exceptions
Type | Condition |
---|---|
NMSException | if the NMS provider fails to write to the message due to some internal error. |
MessageNotWriteableException | if the message is in read-only mode. |
WriteInt16(Int16)
Writes a short to the stream message.
Declaration
void WriteInt16(short value)
Parameters
Type | Name | Description |
---|---|---|
System.Int16 | value | A System.Int16 |
Exceptions
Type | Condition |
---|---|
NMSException | if the NMS provider fails to write to the message due to some internal error. |
MessageNotWriteableException | if the message is in read-only mode. |
WriteInt32(Int32)
Writes a int to the stream message.
Declaration
void WriteInt32(int value)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | value | A System.Int32 |
Exceptions
Type | Condition |
---|---|
NMSException | if the NMS provider fails to write to the message due to some internal error. |
MessageNotWriteableException | if the message is in read-only mode. |
WriteInt64(Int64)
Writes a long to the stream message.
Declaration
void WriteInt64(long value)
Parameters
Type | Name | Description |
---|---|---|
System.Int64 | value | A System.Int64 |
Exceptions
Type | Condition |
---|---|
NMSException | if the NMS provider fails to write to the message due to some internal error. |
MessageNotWriteableException | if the message is in read-only mode. |
WriteObject(Object)
Writes a boolean to the stream message.
Declaration
void WriteObject(object value)
Parameters
Type | Name | Description |
---|---|---|
System.Object | value | A System.Boolean |
Exceptions
Type | Condition |
---|---|
NMSException | if the NMS provider fails to write to the message due to some internal error. |
MessageNotWriteableException | if the message is in read-only mode. |
WriteSingle(Single)
Writes a float to the stream message.
Declaration
void WriteSingle(float value)
Parameters
Type | Name | Description |
---|---|---|
System.Single | value | A System.Single |
Exceptions
Type | Condition |
---|---|
NMSException | if the NMS provider fails to write to the message due to some internal error. |
MessageNotWriteableException | if the message is in read-only mode. |
WriteString(String)
Writes a string to the stream message.
Declaration
void WriteString(string value)
Parameters
Type | Name | Description |
---|---|---|
System.String | value | A System.String |
Exceptions
Type | Condition |
---|---|
NMSException | if the NMS provider fails to write to the message due to some internal error. |
MessageNotWriteableException | if the message is in read-only mode. |