Return-Path: Delivered-To: apmail-activemq-commits-archive@www.apache.org Received: (qmail 13827 invoked from network); 2 Oct 2009 22:58:39 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 2 Oct 2009 22:58:39 -0000 Received: (qmail 89694 invoked by uid 500); 2 Oct 2009 22:58:39 -0000 Delivered-To: apmail-activemq-commits-archive@activemq.apache.org Received: (qmail 89643 invoked by uid 500); 2 Oct 2009 22:58:39 -0000 Mailing-List: contact commits-help@activemq.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@activemq.apache.org Delivered-To: mailing list commits@activemq.apache.org Received: (qmail 89634 invoked by uid 99); 2 Oct 2009 22:58:39 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 02 Oct 2009 22:58:39 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 02 Oct 2009 22:58:29 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id A432A23888D0; Fri, 2 Oct 2009 22:58:06 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r821196 - in /activemq/activemq-dotnet: Apache.NMS.ActiveMQ/trunk/src/main/csharp/Commands/ Apache.NMS.EMS/trunk/src/main/csharp/ Apache.NMS.MSMQ/trunk/src/main/csharp/ Apache.NMS/trunk/src/main/csharp/ Date: Fri, 02 Oct 2009 22:58:06 -0000 To: commits@activemq.apache.org From: jgomes@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20091002225806.A432A23888D0@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: jgomes Date: Fri Oct 2 22:58:05 2009 New Revision: 821196 URL: http://svn.apache.org/viewvc?rev=821196&view=rev Log: Implemented new BytesMessage API for MSMQ and EMS providers. Fixes [AMQNET-162]. (See https://issues.apache.org/activemq/browse/AMQNET-162) Modified: activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Commands/ActiveMQMessage.cs activemq/activemq-dotnet/Apache.NMS.EMS/trunk/src/main/csharp/BytesMessage.cs activemq/activemq-dotnet/Apache.NMS.EMS/trunk/src/main/csharp/Message.cs activemq/activemq-dotnet/Apache.NMS.MSMQ/trunk/src/main/csharp/BaseMessage.cs activemq/activemq-dotnet/Apache.NMS.MSMQ/trunk/src/main/csharp/BytesMessage.cs activemq/activemq-dotnet/Apache.NMS.MSMQ/trunk/src/main/csharp/ObjectMessage.cs activemq/activemq-dotnet/Apache.NMS.MSMQ/trunk/src/main/csharp/TextMessage.cs activemq/activemq-dotnet/Apache.NMS/trunk/src/main/csharp/IBytesMessage.cs activemq/activemq-dotnet/Apache.NMS/trunk/src/main/csharp/IMessage.cs Modified: activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Commands/ActiveMQMessage.cs URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Commands/ActiveMQMessage.cs?rev=821196&r1=821195&r2=821196&view=diff ============================================================================== --- activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Commands/ActiveMQMessage.cs (original) +++ activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Commands/ActiveMQMessage.cs Fri Oct 2 22:58:05 2009 @@ -63,35 +63,35 @@ Acknowledger(this); } } - - public virtual void ClearBody() - { - this.Content = null; - this.readOnlyMsgBody = false; - } - - public virtual void ClearProperties() - { - this.MarshalledProperties = null; - this.Properties.Clear(); - this.readOnlyMsgProperties = false; - } - - protected void FailIfReadOnlyBody() - { - if(ReadOnlyBody == true) - { - throw new MessageNotWriteableException("Message is in Read-Only mode."); - } - } - - protected void FailIfWriteOnlyBody() - { - if( ReadOnlyBody == false ) - { - throw new MessageNotReadableException("Message is in Write-Only mode."); - } - } + + public virtual void ClearBody() + { + this.Content = null; + this.readOnlyMsgBody = false; + } + + public virtual void ClearProperties() + { + this.MarshalledProperties = null; + this.Properties.Clear(); + this.readOnlyMsgProperties = false; + } + + protected void FailIfReadOnlyBody() + { + if(ReadOnlyBody == true) + { + throw new MessageNotWriteableException("Message is in Read-Only mode."); + } + } + + protected void FailIfWriteOnlyBody() + { + if( ReadOnlyBody == false ) + { + throw new MessageNotReadableException("Message is in Write-Only mode."); + } + } #region Properties Modified: activemq/activemq-dotnet/Apache.NMS.EMS/trunk/src/main/csharp/BytesMessage.cs URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.EMS/trunk/src/main/csharp/BytesMessage.cs?rev=821196&r1=821195&r2=821196&view=diff ============================================================================== --- activemq/activemq-dotnet/Apache.NMS.EMS/trunk/src/main/csharp/BytesMessage.cs (original) +++ activemq/activemq-dotnet/Apache.NMS.EMS/trunk/src/main/csharp/BytesMessage.cs Fri Oct 2 22:58:05 2009 @@ -51,6 +51,131 @@ } } + public long BodyLength + { + get { return this.tibcoBytesMessage.BodyLength; } + } + + public bool ReadBoolean() + { + return this.tibcoBytesMessage.ReadBoolean(); + } + + public byte ReadByte() + { + return (byte) this.tibcoBytesMessage.ReadByte(); + } + + public int ReadBytes(byte[] value, int length) + { + return this.tibcoBytesMessage.ReadBytes(value, length); + } + + public int ReadBytes(byte[] value) + { + return this.tibcoBytesMessage.ReadBytes(value); + } + + public char ReadChar() + { + return this.tibcoBytesMessage.ReadChar(); + } + + public double ReadDouble() + { + return this.tibcoBytesMessage.ReadDouble(); + } + + public short ReadInt16() + { + return this.tibcoBytesMessage.ReadShort(); + } + + public int ReadInt32() + { + return this.tibcoBytesMessage.ReadInt(); + } + + public long ReadInt64() + { + return this.tibcoBytesMessage.ReadLong(); + } + + public float ReadSingle() + { + return this.tibcoBytesMessage.ReadFloat(); + } + + public string ReadString() + { + return this.tibcoBytesMessage.ReadUTF(); + } + + public void Reset() + { + this.tibcoBytesMessage.Reset(); + } + + public void WriteBoolean(bool value) + { + this.tibcoBytesMessage.WriteBoolean(value); + } + + public void WriteByte(byte value) + { + this.tibcoBytesMessage.WriteByte(value); + } + + public void WriteBytes(byte[] value, int offset, int length) + { + this.tibcoBytesMessage.WriteBytes(value, offset, length); + } + + public void WriteBytes(byte[] value) + { + this.tibcoBytesMessage.WriteBytes(value); + } + + public void WriteChar(char value) + { + this.tibcoBytesMessage.WriteChar(value); + } + + public void WriteDouble(double value) + { + this.tibcoBytesMessage.WriteDouble(value); + } + + public void WriteInt16(short value) + { + this.tibcoBytesMessage.WriteShort(value); + } + + public void WriteInt32(int value) + { + this.tibcoBytesMessage.WriteInt(value); + } + + public void WriteInt64(long value) + { + this.tibcoBytesMessage.WriteLong(value); + } + + public void WriteObject(object value) + { + this.tibcoBytesMessage.WriteObject(value); + } + + public void WriteSingle(float value) + { + this.tibcoBytesMessage.WriteFloat(value); + } + + public void WriteString(string value) + { + this.tibcoBytesMessage.WriteUTF(value); + } + #endregion } } Modified: activemq/activemq-dotnet/Apache.NMS.EMS/trunk/src/main/csharp/Message.cs URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.EMS/trunk/src/main/csharp/Message.cs?rev=821196&r1=821195&r2=821196&view=diff ============================================================================== --- activemq/activemq-dotnet/Apache.NMS.EMS/trunk/src/main/csharp/Message.cs (original) +++ activemq/activemq-dotnet/Apache.NMS.EMS/trunk/src/main/csharp/Message.cs Fri Oct 2 22:58:05 2009 @@ -40,6 +40,28 @@ } /// + /// 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. + /// + public void ClearBody() + { + this.tibcoMessage.ClearBody(); + } + + /// + /// Clears a message's properties. + /// + /// The message's header fields and body are not cleared. + /// + public void ClearProperties() + { + this.tibcoMessage.ClearProperties(); + } + + /// /// Provides access to the message properties (headers) /// public Apache.NMS.IPrimitiveMap Properties Modified: activemq/activemq-dotnet/Apache.NMS.MSMQ/trunk/src/main/csharp/BaseMessage.cs URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.MSMQ/trunk/src/main/csharp/BaseMessage.cs?rev=821196&r1=821195&r2=821196&view=diff ============================================================================== --- activemq/activemq-dotnet/Apache.NMS.MSMQ/trunk/src/main/csharp/BaseMessage.cs (original) +++ activemq/activemq-dotnet/Apache.NMS.MSMQ/trunk/src/main/csharp/BaseMessage.cs Fri Oct 2 22:58:05 2009 @@ -34,15 +34,17 @@ private Destination replyTo; private string type; private event AcknowledgeHandler Acknowledger; - private byte[] content; private DateTime timestamp = new DateTime(); + private bool readOnlyMsgBody = false; - public byte[] Content + public bool ReadOnlyBody { - get { return content; } - set { content = value; } + get { return readOnlyMsgBody; } + set { readOnlyMsgBody = value; } } + // IMessage interface + public void Acknowledge() { if(null != Acknowledger) @@ -51,6 +53,28 @@ } } + /// + /// 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. + /// + public virtual void ClearBody() + { + this.readOnlyMsgBody = false; + } + + /// + /// Clears a message's properties. + /// + /// The message's header fields and body are not cleared. + /// + public virtual void ClearProperties() + { + propertiesMap.Clear(); + } + // Properties public IPrimitiveMap Properties @@ -59,8 +83,6 @@ } - // IMessage interface - // NMS headers /// @@ -163,6 +185,22 @@ public void SetObjectProperty(string name, object value) { } + + protected void FailIfReadOnlyBody() + { + if(ReadOnlyBody == true) + { + throw new MessageNotWriteableException("Message is in Read-Only mode."); + } + } + + protected void FailIfWriteOnlyBody() + { + if( ReadOnlyBody == false ) + { + throw new MessageNotReadableException("Message is in Write-Only mode."); + } + } } } Modified: activemq/activemq-dotnet/Apache.NMS.MSMQ/trunk/src/main/csharp/BytesMessage.cs URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.MSMQ/trunk/src/main/csharp/BytesMessage.cs?rev=821196&r1=821195&r2=821196&view=diff ============================================================================== --- activemq/activemq-dotnet/Apache.NMS.MSMQ/trunk/src/main/csharp/BytesMessage.cs (original) +++ activemq/activemq-dotnet/Apache.NMS.MSMQ/trunk/src/main/csharp/BytesMessage.cs Fri Oct 2 22:58:05 2009 @@ -16,10 +16,503 @@ */ +using Apache.NMS.Util; +using System.IO; +using System; namespace Apache.NMS.MSMQ { + /// + /// + /// A BytesMessage object is used to send a message containing a stream of uninterpreted + /// bytes. It inherits from the Message interface and adds a bytes message body. The + /// receiver of the message supplies the interpretation of the bytes. + /// + /// This message type is for client encoding of existing message formats. If possible, + /// one of the other self-defining message types should be used instead. + /// + /// Although the NMS API allows the use of message properties with byte messages, they + /// are typically not used, since the inclusion of properties may affect the format. + /// + /// 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. + /// public class BytesMessage : BaseMessage, IBytesMessage { + private EndianBinaryReader dataIn = null; + private EndianBinaryWriter dataOut = null; + private MemoryStream outputBuffer = null; + private byte[] content; + + // Need this later when we add compression to store true content length. + private long length = 0; + + public byte[] Content + { + get { StoreContent(); return content; } + set { content = value; } + } + + public override void ClearBody() + { + base.ClearBody(); + this.outputBuffer = null; + this.dataIn = null; + this.dataOut = null; + this.length = 0; + } + + public long BodyLength + { + get + { + InitializeReading(); + return this.length; + } + } + + public byte ReadByte() + { + InitializeReading(); + try + { + return dataIn.ReadByte(); + } + catch(EndOfStreamException e) + { + throw NMSExceptionSupport.createMessageEOFException(e); + } + catch(IOException e) + { + throw NMSExceptionSupport.createMessageFormatException(e); + } + } + + public void WriteByte( byte value ) + { + InitializeWriting(); + try + { + dataOut.Write( value ); + } + catch(Exception e) + { + throw NMSExceptionSupport.create(e); + } + } + + public bool ReadBoolean() + { + InitializeReading(); + try + { + return dataIn.ReadBoolean(); + } + catch(EndOfStreamException e) + { + throw NMSExceptionSupport.createMessageEOFException(e); + } + catch(IOException e) + { + throw NMSExceptionSupport.createMessageFormatException(e); + } + } + + public void WriteBoolean( bool value ) + { + InitializeWriting(); + try + { + dataOut.Write( value ); + } + catch(Exception e) + { + throw NMSExceptionSupport.create(e); + } + } + + public char ReadChar() + { + InitializeReading(); + try + { + return dataIn.ReadChar(); + } + catch(EndOfStreamException e) + { + throw NMSExceptionSupport.createMessageEOFException(e); + } + catch(IOException e) + { + throw NMSExceptionSupport.createMessageFormatException(e); + } + } + + public void WriteChar( char value ) + { + InitializeWriting(); + try + { + dataOut.Write( value ); + } + catch(Exception e) + { + throw NMSExceptionSupport.create(e); + } + } + + public short ReadInt16() + { + InitializeReading(); + try + { + return dataIn.ReadInt16(); + } + catch(EndOfStreamException e) + { + throw NMSExceptionSupport.createMessageEOFException(e); + } + catch(IOException e) + { + throw NMSExceptionSupport.createMessageFormatException(e); + } + } + + public void WriteInt16( short value ) + { + InitializeWriting(); + try + { + dataOut.Write( value ); + } + catch(Exception e) + { + throw NMSExceptionSupport.create(e); + } + } + + public int ReadInt32() + { + InitializeReading(); + try + { + return dataIn.ReadInt32(); + } + catch(EndOfStreamException e) + { + throw NMSExceptionSupport.createMessageEOFException(e); + } + catch(IOException e) + { + throw NMSExceptionSupport.createMessageFormatException(e); + } + } + + public void WriteInt32( int value ) + { + InitializeWriting(); + try + { + dataOut.Write( value ); + } + catch(Exception e) + { + throw NMSExceptionSupport.create(e); + } + } + + public long ReadInt64() + { + InitializeReading(); + try + { + return dataIn.ReadInt64(); + } + catch(EndOfStreamException e) + { + throw NMSExceptionSupport.createMessageEOFException(e); + } + catch(IOException e) + { + throw NMSExceptionSupport.createMessageFormatException(e); + } + } + + public void WriteInt64( long value ) + { + InitializeWriting(); + try + { + dataOut.Write( value ); + } + catch(Exception e) + { + throw NMSExceptionSupport.create(e); + } + } + + public float ReadSingle() + { + InitializeReading(); + try + { + return dataIn.ReadSingle(); + } + catch(EndOfStreamException e) + { + throw NMSExceptionSupport.createMessageEOFException(e); + } + catch(IOException e) + { + throw NMSExceptionSupport.createMessageFormatException(e); + } + } + + public void WriteSingle( float value ) + { + InitializeWriting(); + try + { + dataOut.Write( value ); + } + catch(Exception e) + { + throw NMSExceptionSupport.create(e); + } + } + + public double ReadDouble() + { + InitializeReading(); + try + { + return dataIn.ReadDouble(); + } + catch(EndOfStreamException e) + { + throw NMSExceptionSupport.createMessageEOFException(e); + } + catch(IOException e) + { + throw NMSExceptionSupport.createMessageFormatException(e); + } + } + + public void WriteDouble( double value ) + { + InitializeWriting(); + try + { + dataOut.Write( value ); + } + catch(Exception e) + { + throw NMSExceptionSupport.create(e); + } + } + + public int ReadBytes( byte[] value ) + { + InitializeReading(); + try + { + return dataIn.Read( value, 0, value.Length ); + } + catch(EndOfStreamException e) + { + throw NMSExceptionSupport.createMessageEOFException(e); + } + catch(IOException e) + { + throw NMSExceptionSupport.createMessageFormatException(e); + } + } + + public int ReadBytes( byte[] value, int length ) + { + InitializeReading(); + try + { + return dataIn.Read( value, 0, length ); + } + catch(EndOfStreamException e) + { + throw NMSExceptionSupport.createMessageEOFException(e); + } + catch(IOException e) + { + throw NMSExceptionSupport.createMessageFormatException(e); + } + } + + public void WriteBytes( byte[] value ) + { + InitializeWriting(); + try + { + dataOut.Write( value, 0, value.Length ); + } + catch(Exception e) + { + throw NMSExceptionSupport.create(e); + } + } + + public void WriteBytes( byte[] value, int offset, int length ) + { + InitializeWriting(); + try + { + dataOut.Write( value, offset, length ); + } + catch(Exception e) + { + throw NMSExceptionSupport.create(e); + } + } + + public string ReadString() + { + InitializeReading(); + try + { + // JMS, CMS and NMS all encode the String using a 16 bit size header. + return dataIn.ReadString16(); + } + catch(EndOfStreamException e) + { + throw NMSExceptionSupport.createMessageEOFException(e); + } + catch(IOException e) + { + throw NMSExceptionSupport.createMessageFormatException(e); + } + } + + public void WriteString( string value ) + { + InitializeWriting(); + try + { + // JMS, CMS and NMS all encode the String using a 16 bit size header. + dataOut.WriteString16(value); + } + catch(Exception e) + { + throw NMSExceptionSupport.create(e); + } + } + + public void WriteObject( System.Object value ) + { + InitializeWriting(); + if( value is System.Byte ) + { + this.dataOut.Write( (byte) value ); + } + else if( value is Char ) + { + this.dataOut.Write( (char) value ); + } + else if( value is Boolean ) + { + this.dataOut.Write( (bool) value ); + } + else if( value is Int16 ) + { + this.dataOut.Write( (short) value ); + } + else if( value is Int32 ) + { + this.dataOut.Write( (int) value ); + } + else if( value is Int64 ) + { + this.dataOut.Write( (long) value ); + } + else if( value is Single ) + { + this.dataOut.Write( (float) value ); + } + else if( value is Double ) + { + this.dataOut.Write( (double) value ); + } + else if( value is byte[] ) + { + this.dataOut.Write( (byte[]) value ); + } + else if( value is String ) + { + this.dataOut.WriteString16( (string) value ); + } + else + { + throw new MessageFormatException("Cannot write non-primitive type:" + value.GetType()); + } + } + + public void Reset() + { + StoreContent(); + this.dataIn = null; + this.dataOut = null; + this.outputBuffer = null; + this.ReadOnlyBody = true; + } + + private void InitializeReading() + { + FailIfWriteOnlyBody(); + if(this.dataIn == null) + { + if(this.Content != null) + { + this.length = this.Content.Length; + } + + // TODO - Add support for Message Compression. + MemoryStream bytesIn = new MemoryStream(this.Content, false); + dataIn = new EndianBinaryReader(bytesIn); + } + } + + private void InitializeWriting() + { + FailIfReadOnlyBody(); + if(this.dataOut == null) + { + // TODO - Add support for Message Compression. + this.outputBuffer = new MemoryStream(); + this.dataOut = new EndianBinaryWriter(outputBuffer); + } + } + + private void StoreContent() + { + if( dataOut != null) + { + dataOut.Close(); + // TODO - Add support for Message Compression. + + this.Content = outputBuffer.ToArray(); + this.dataOut = null; + this.outputBuffer = null; + } + } } } Modified: activemq/activemq-dotnet/Apache.NMS.MSMQ/trunk/src/main/csharp/ObjectMessage.cs URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.MSMQ/trunk/src/main/csharp/ObjectMessage.cs?rev=821196&r1=821195&r2=821196&view=diff ============================================================================== --- activemq/activemq-dotnet/Apache.NMS.MSMQ/trunk/src/main/csharp/ObjectMessage.cs (original) +++ activemq/activemq-dotnet/Apache.NMS.MSMQ/trunk/src/main/csharp/ObjectMessage.cs Fri Oct 2 22:58:05 2009 @@ -30,6 +30,7 @@ #if !(PocketPC||NETCF||NETCF_2_0) private IFormatter formatter; #endif + public byte[] Content; public ObjectMessage() { Modified: activemq/activemq-dotnet/Apache.NMS.MSMQ/trunk/src/main/csharp/TextMessage.cs URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.MSMQ/trunk/src/main/csharp/TextMessage.cs?rev=821196&r1=821195&r2=821196&view=diff ============================================================================== --- activemq/activemq-dotnet/Apache.NMS.MSMQ/trunk/src/main/csharp/TextMessage.cs (original) +++ activemq/activemq-dotnet/Apache.NMS.MSMQ/trunk/src/main/csharp/TextMessage.cs Fri Oct 2 22:58:05 2009 @@ -22,6 +22,7 @@ public class TextMessage : BaseMessage, ITextMessage { public const int SIZE_OF_INT = 4; // sizeof(int) - though causes unsafe issues with net 1.1 + public byte[] Content; private String text; Modified: activemq/activemq-dotnet/Apache.NMS/trunk/src/main/csharp/IBytesMessage.cs URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS/trunk/src/main/csharp/IBytesMessage.cs?rev=821196&r1=821195&r2=821196&view=diff ============================================================================== --- activemq/activemq-dotnet/Apache.NMS/trunk/src/main/csharp/IBytesMessage.cs (original) +++ activemq/activemq-dotnet/Apache.NMS/trunk/src/main/csharp/IBytesMessage.cs Fri Oct 2 22:58:05 2009 @@ -17,470 +17,470 @@ namespace Apache.NMS { /// - /// + /// /// A BytesMessage object is used to send a message containing a stream of uninterpreted - /// bytes. It inherits from the Message interface and adds a bytes message body. The - /// receiver of the message supplies the interpretation of the bytes. - /// - /// This message type is for client encoding of existing message formats. If possible, - /// one of the other self-defining message types should be used instead. - /// - /// Although the NMS API allows the use of message properties with byte messages, they - /// are typically not used, since the inclusion of properties may affect the format. - /// - /// 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. + /// bytes. It inherits from the Message interface and adds a bytes message body. The + /// receiver of the message supplies the interpretation of the bytes. + /// + /// This message type is for client encoding of existing message formats. If possible, + /// one of the other self-defining message types should be used instead. + /// + /// Although the NMS API allows the use of message properties with byte messages, they + /// are typically not used, since the inclusion of properties may affect the format. + /// + /// 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. /// public interface IBytesMessage : IMessage { byte[] Content { get; set; } - - /// - /// Gets the number of bytes of the message body when the message is in read-only mode. - /// The value returned can be used to allocate a byte array. The value returned is the - /// entire length of the message body, regardless of where the pointer for reading the - /// message is currently located. - /// - /// - /// Thrown when the Message is in write-only mode. - /// - /// - /// Thrown when there is an unhandled exception thrown from the provider. - /// - long BodyLength { get; } - - /// - /// Reads a byte from the Message Stream. - /// - /// - /// A - /// - /// - /// Thrown when the Message is in write-only mode. - /// - /// - /// Thrown when an unexpected end of bytes has been reached. - /// - /// - /// Thrown when there is an unhandled exception thrown from the provider. - /// - byte ReadByte(); - - /// - /// Writes a byte to the Message stream. - /// - /// - /// A - /// - /// - /// Thrown when the Message is in read-only mode. - /// - /// - /// Thrown when there is an unhandled exception thrown from the provider. - /// - void WriteByte( byte value ); - - /// - /// Reads a boolean from the Message Stream. - /// - /// - /// A - /// - /// - /// Thrown when the Message is in write-only mode. - /// - /// - /// Thrown when an unexpected end of bytes has been reached. - /// - /// - /// Thrown when there is an unhandled exception thrown from the provider. - /// - bool ReadBoolean(); - - /// - /// Write a one byte value to the message stream representing the boolean - /// value passed. - /// - /// - /// A - /// - /// - /// Thrown when the Message is in read-only mode. - /// - /// - /// Thrown when there is an unhandled exception thrown from the provider. - /// - void WriteBoolean( bool value ); - - /// - /// Reads a char from the Message Stream. - /// - /// - /// A - /// - /// - /// Thrown when the Message is in write-only mode. - /// - /// - /// Thrown when an unexpected end of bytes has been reached. - /// - /// - /// Thrown when there is an unhandled exception thrown from the provider. - /// - char ReadChar(); - - /// - /// Write a two byte value to the message stream representing the character - /// value passed. High byte first. - /// - /// - /// A - /// - /// - /// Thrown when the Message is in read-only mode. - /// - /// - /// Thrown when there is an unhandled exception thrown from the provider. - /// - void WriteChar( char value ); - - /// - /// Reads a Short from the Message Stream. - /// - /// - /// A - /// - /// - /// Thrown when the Message is in write-only mode. - /// - /// - /// Thrown when an unexpected end of bytes has been reached. - /// - /// - /// Thrown when there is an unhandled exception thrown from the provider. - /// - short ReadInt16(); - - /// - /// Write a two byte value to the message stream representing the short - /// value passed. High byte first. - /// - /// - /// A - /// - /// - /// Thrown when the Message is in read-only mode. - /// - /// - /// Thrown when there is an unhandled exception thrown from the provider. - /// - void WriteInt16( short value ); - - /// - /// Reads an int from the Message Stream. - /// - /// - /// A - /// - /// - /// Thrown when the Message is in write-only mode. - /// - /// - /// Thrown when an unexpected end of bytes has been reached. - /// - /// - /// Thrown when there is an unhandled exception thrown from the provider. - /// - int ReadInt32(); - - /// - /// Write a four byte value to the message stream representing the integer - /// value passed. High byte first. - /// - /// - /// A - /// - /// - /// Thrown when the Message is in read-only mode. - /// - /// - /// Thrown when there is an unhandled exception thrown from the provider. - /// - void WriteInt32( int value ); - - /// - /// Reads a long from the Message Stream. - /// - /// - /// A - /// - /// - /// Thrown when the Message is in write-only mode. - /// - /// - /// Thrown when an unexpected end of bytes has been reached. - /// - /// - /// Thrown when there is an unhandled exception thrown from the provider. - /// - long ReadInt64(); - - /// - /// Write a eight byte value to the message stream representing the long - /// value passed. High byte first. - /// - /// - /// A - /// - /// - /// Thrown when the Message is in read-only mode. - /// - /// - /// Thrown when there is an unhandled exception thrown from the provider. - /// - void WriteInt64( long value ); - - /// - /// Reads a float from the Message Stream. - /// - /// - /// A - /// - /// - /// Thrown when the Message is in write-only mode. - /// - /// - /// Thrown when an unexpected end of bytes has been reached. - /// - /// - /// Thrown when there is an unhandled exception thrown from the provider. - /// - float ReadSingle(); - - /// - /// Write a four byte value to the message stream representing the float - /// value passed. High byte first. - /// - /// - /// A - /// - /// - /// Thrown when the Message is in read-only mode. - /// - /// - /// Thrown when there is an unhandled exception thrown from the provider. - /// - void WriteSingle( float value ); - - /// - /// Reads an double from the Message Stream. - /// - /// - /// A - /// - /// - /// Thrown when the Message is in write-only mode. - /// - /// - /// Thrown when an unexpected end of bytes has been reached. - /// - /// - /// Thrown when there is an unhandled exception thrown from the provider. - /// - double ReadDouble(); - - /// - /// Write a eight byte value to the message stream representing the double - /// value passed. High byte first. - /// - /// - /// A - /// - /// - /// Thrown when the Message is in read-only mode. - /// - /// - /// Thrown when there is an unhandled exception thrown from the provider. - /// - void WriteDouble( double value ); - - /// - /// Reads a byte array from 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. - /// - /// - /// The byte array that will be used as a buffer to read into. - /// - /// - /// A - /// The number of bytes read into the passed byte array, or -1 if there are no more - /// bytes left to be read from the stream. - /// - /// - /// Thrown when there is an unhandled exception thrown from the provider. - /// - /// - /// Thrown when the Message is in write-only mode. - /// - int ReadBytes( byte[] value ); - - /// - /// 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 Exception is thrown. No bytes will be read from the stream for this - /// exception case. - /// - /// - /// The byte array that will be used as a buffer to read into. - /// - /// - /// The amount of bytes to read into the buffer. - /// - /// - /// A - /// The number of bytes read into the passed byte array, or -1 if there are no more - /// bytes left to be read from the stream. - /// - /// - /// Thrown when the Message is in write-only mode. - /// - /// - /// Thrown when there is an unhandled exception thrown from the provider. - /// - int ReadBytes( byte[] value, int length ); - - /// - /// Writes a byte array to the bytes message stream. - /// - /// - /// A - /// - /// - /// Thrown when the Message is in read-only mode. - /// - /// - /// Thrown when there is an unhandled exception thrown from the provider. - /// - void WriteBytes( byte[] value ); - - /// - /// Writes a portion of a byte array to the bytes message stream. - /// - /// - /// A - /// - /// - /// A - /// - /// - /// A - /// - /// - /// Thrown when the Message is in read-only mode. - /// - /// - /// Thrown when there is an unhandled exception thrown from the provider. - /// - void WriteBytes( byte[] value, int offset, int length ); - - /// - /// Reads a string that has been encoded using a modified UTF-8 format from the bytes - /// message stream. - /// - /// - /// A - /// - /// - /// Thrown when the Message is in write-only mode. - /// - /// - /// Thrown when an unexpected end of bytes has been reached. - /// - /// - /// Thrown when there is an unhandled exception thrown from the provider. - /// - string ReadString(); - - /// - /// Writes a string to the bytes message stream using UTF-8 encoding in a - /// machine-independent manner. - /// - /// - /// A - /// - /// - /// Thrown when the Message is in read-only mode. - /// - /// - /// Thrown when there is an unhandled exception thrown from the provider. - /// - void WriteString( string value ); - - /// - /// Writes an object to the bytes message stream. - /// - /// This method works only for the objectified primitive object types - /// (Int32, Double, Boolean ...), String objects, and byte arrays. - /// - /// - /// A - /// the object in the .NET programming language to be written; it must not be null - /// - /// - /// Thrown when the Message has an invalid format. - /// - /// - /// Thrown when the Message is in read-only mode. - /// - /// - /// Thrown when there is an unhandled exception thrown from the provider. - /// - void WriteObject( System.Object value ); - - /// - /// Puts the message body in read-only mode and repositions the stream of bytes to the beginning. - /// - /// - /// Thrown when the Message has an invalid format. - /// - /// - /// Thrown when there is an unhandled exception thrown from the provider. - /// - void Reset(); - + + /// + /// Gets the number of bytes of the message body when the message is in read-only mode. + /// The value returned can be used to allocate a byte array. The value returned is the + /// entire length of the message body, regardless of where the pointer for reading the + /// message is currently located. + /// + /// + /// Thrown when the Message is in write-only mode. + /// + /// + /// Thrown when there is an unhandled exception thrown from the provider. + /// + long BodyLength { get; } + + /// + /// Reads a byte from the Message Stream. + /// + /// + /// A + /// + /// + /// Thrown when the Message is in write-only mode. + /// + /// + /// Thrown when an unexpected end of bytes has been reached. + /// + /// + /// Thrown when there is an unhandled exception thrown from the provider. + /// + byte ReadByte(); + + /// + /// Writes a byte to the Message stream. + /// + /// + /// A + /// + /// + /// Thrown when the Message is in read-only mode. + /// + /// + /// Thrown when there is an unhandled exception thrown from the provider. + /// + void WriteByte( byte value ); + + /// + /// Reads a boolean from the Message Stream. + /// + /// + /// A + /// + /// + /// Thrown when the Message is in write-only mode. + /// + /// + /// Thrown when an unexpected end of bytes has been reached. + /// + /// + /// Thrown when there is an unhandled exception thrown from the provider. + /// + bool ReadBoolean(); + + /// + /// Write a one byte value to the message stream representing the boolean + /// value passed. + /// + /// + /// A + /// + /// + /// Thrown when the Message is in read-only mode. + /// + /// + /// Thrown when there is an unhandled exception thrown from the provider. + /// + void WriteBoolean( bool value ); + + /// + /// Reads a char from the Message Stream. + /// + /// + /// A + /// + /// + /// Thrown when the Message is in write-only mode. + /// + /// + /// Thrown when an unexpected end of bytes has been reached. + /// + /// + /// Thrown when there is an unhandled exception thrown from the provider. + /// + char ReadChar(); + + /// + /// Write a two byte value to the message stream representing the character + /// value passed. High byte first. + /// + /// + /// A + /// + /// + /// Thrown when the Message is in read-only mode. + /// + /// + /// Thrown when there is an unhandled exception thrown from the provider. + /// + void WriteChar( char value ); + + /// + /// Reads a Short from the Message Stream. + /// + /// + /// A + /// + /// + /// Thrown when the Message is in write-only mode. + /// + /// + /// Thrown when an unexpected end of bytes has been reached. + /// + /// + /// Thrown when there is an unhandled exception thrown from the provider. + /// + short ReadInt16(); + + /// + /// Write a two byte value to the message stream representing the short + /// value passed. High byte first. + /// + /// + /// A + /// + /// + /// Thrown when the Message is in read-only mode. + /// + /// + /// Thrown when there is an unhandled exception thrown from the provider. + /// + void WriteInt16( short value ); + + /// + /// Reads an int from the Message Stream. + /// + /// + /// A + /// + /// + /// Thrown when the Message is in write-only mode. + /// + /// + /// Thrown when an unexpected end of bytes has been reached. + /// + /// + /// Thrown when there is an unhandled exception thrown from the provider. + /// + int ReadInt32(); + + /// + /// Write a four byte value to the message stream representing the integer + /// value passed. High byte first. + /// + /// + /// A + /// + /// + /// Thrown when the Message is in read-only mode. + /// + /// + /// Thrown when there is an unhandled exception thrown from the provider. + /// + void WriteInt32( int value ); + + /// + /// Reads a long from the Message Stream. + /// + /// + /// A + /// + /// + /// Thrown when the Message is in write-only mode. + /// + /// + /// Thrown when an unexpected end of bytes has been reached. + /// + /// + /// Thrown when there is an unhandled exception thrown from the provider. + /// + long ReadInt64(); + + /// + /// Write a eight byte value to the message stream representing the long + /// value passed. High byte first. + /// + /// + /// A + /// + /// + /// Thrown when the Message is in read-only mode. + /// + /// + /// Thrown when there is an unhandled exception thrown from the provider. + /// + void WriteInt64( long value ); + + /// + /// Reads a float from the Message Stream. + /// + /// + /// A + /// + /// + /// Thrown when the Message is in write-only mode. + /// + /// + /// Thrown when an unexpected end of bytes has been reached. + /// + /// + /// Thrown when there is an unhandled exception thrown from the provider. + /// + float ReadSingle(); + + /// + /// Write a four byte value to the message stream representing the float + /// value passed. High byte first. + /// + /// + /// A + /// + /// + /// Thrown when the Message is in read-only mode. + /// + /// + /// Thrown when there is an unhandled exception thrown from the provider. + /// + void WriteSingle( float value ); + + /// + /// Reads an double from the Message Stream. + /// + /// + /// A + /// + /// + /// Thrown when the Message is in write-only mode. + /// + /// + /// Thrown when an unexpected end of bytes has been reached. + /// + /// + /// Thrown when there is an unhandled exception thrown from the provider. + /// + double ReadDouble(); + + /// + /// Write a eight byte value to the message stream representing the double + /// value passed. High byte first. + /// + /// + /// A + /// + /// + /// Thrown when the Message is in read-only mode. + /// + /// + /// Thrown when there is an unhandled exception thrown from the provider. + /// + void WriteDouble( double value ); + + /// + /// Reads a byte array from 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. + /// + /// + /// The byte array that will be used as a buffer to read into. + /// + /// + /// A + /// The number of bytes read into the passed byte array, or -1 if there are no more + /// bytes left to be read from the stream. + /// + /// + /// Thrown when there is an unhandled exception thrown from the provider. + /// + /// + /// Thrown when the Message is in write-only mode. + /// + int ReadBytes( byte[] value ); + + /// + /// 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 Exception is thrown. No bytes will be read from the stream for this + /// exception case. + /// + /// + /// The byte array that will be used as a buffer to read into. + /// + /// + /// The amount of bytes to read into the buffer. + /// + /// + /// A + /// The number of bytes read into the passed byte array, or -1 if there are no more + /// bytes left to be read from the stream. + /// + /// + /// Thrown when the Message is in write-only mode. + /// + /// + /// Thrown when there is an unhandled exception thrown from the provider. + /// + int ReadBytes( byte[] value, int length ); + + /// + /// Writes a byte array to the bytes message stream. + /// + /// + /// A + /// + /// + /// Thrown when the Message is in read-only mode. + /// + /// + /// Thrown when there is an unhandled exception thrown from the provider. + /// + void WriteBytes( byte[] value ); + + /// + /// Writes a portion of a byte array to the bytes message stream. + /// + /// + /// A + /// + /// + /// A + /// + /// + /// A + /// + /// + /// Thrown when the Message is in read-only mode. + /// + /// + /// Thrown when there is an unhandled exception thrown from the provider. + /// + void WriteBytes( byte[] value, int offset, int length ); + + /// + /// Reads a string that has been encoded using a modified UTF-8 format from the bytes + /// message stream. + /// + /// + /// A + /// + /// + /// Thrown when the Message is in write-only mode. + /// + /// + /// Thrown when an unexpected end of bytes has been reached. + /// + /// + /// Thrown when there is an unhandled exception thrown from the provider. + /// + string ReadString(); + + /// + /// Writes a string to the bytes message stream using UTF-8 encoding in a + /// machine-independent manner. + /// + /// + /// A + /// + /// + /// Thrown when the Message is in read-only mode. + /// + /// + /// Thrown when there is an unhandled exception thrown from the provider. + /// + void WriteString( string value ); + + /// + /// Writes an object to the bytes message stream. + /// + /// This method works only for the objectified primitive object types + /// (Int32, Double, Boolean ...), String objects, and byte arrays. + /// + /// + /// A + /// the object in the .NET programming language to be written; it must not be null + /// + /// + /// Thrown when the Message has an invalid format. + /// + /// + /// Thrown when the Message is in read-only mode. + /// + /// + /// Thrown when there is an unhandled exception thrown from the provider. + /// + void WriteObject( System.Object value ); + + /// + /// Puts the message body in read-only mode and repositions the stream of bytes to the beginning. + /// + /// + /// Thrown when the Message has an invalid format. + /// + /// + /// Thrown when there is an unhandled exception thrown from the provider. + /// + void Reset(); + } } Modified: activemq/activemq-dotnet/Apache.NMS/trunk/src/main/csharp/IMessage.cs URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS/trunk/src/main/csharp/IMessage.cs?rev=821196&r1=821195&r2=821196&view=diff ============================================================================== --- activemq/activemq-dotnet/Apache.NMS/trunk/src/main/csharp/IMessage.cs (original) +++ activemq/activemq-dotnet/Apache.NMS/trunk/src/main/csharp/IMessage.cs Fri Oct 2 22:58:05 2009 @@ -28,74 +28,74 @@ /// message has been processed correctly. /// void Acknowledge(); - - /// - /// 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. - /// - void ClearBody(); - - /// - /// Clears a message's properties. - /// - /// The message's header fields and body are not cleared. - /// - void ClearProperties(); - + + /// + /// 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. + /// + void ClearBody(); + + /// + /// Clears a message's properties. + /// + /// The message's header fields and body are not cleared. + /// + void ClearProperties(); + /// /// Provides access to the message properties (headers). /// IPrimitiveMap Properties { get; } - + /// /// The correlation ID used to correlate messages from conversations or long running business processes. /// string NMSCorrelationID { get; set; } - + /// /// The destination of the message. This property is set by the IMessageProducer. /// IDestination NMSDestination { get; } - + /// /// The amount of time for which this message is valid. Zero if this message does not expire. /// TimeSpan NMSTimeToLive { get; set; } - + /// /// The message ID which is set by the provider. /// string NMSMessageId { get; } - + /// /// Whether or not this message is persistent. /// MsgDeliveryMode NMSDeliveryMode { get; set; } - + /// /// The Priority of this message. /// MsgPriority NMSPriority { get; set; } - + /// /// Returns true if this message has been redelivered to this or another consumer before being acknowledged successfully. /// bool NMSRedelivered { get; } - + /// /// The destination that the consumer of this message should send replies to /// IDestination NMSReplyTo { get; set; } - + /// - /// The timestamp of when the message was pubished in UTC time. If the publisher disables setting + /// The timestamp of when the message was pubished in UTC time. If the publisher disables setting /// the timestamp on the message, the time will be set to the start of the UNIX epoc (1970-01-01 00:00:00). /// DateTime NMSTimestamp { get; } - + /// /// The type name of this message. ///