activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jgo...@apache.org
Subject svn commit: r822538 [1/2] - in /activemq/activemq-dotnet: Apache.NMS.ActiveMQ/trunk/src/main/csharp/ Apache.NMS.ActiveMQ/trunk/src/main/csharp/Commands/ Apache.NMS.EMS/trunk/ Apache.NMS.EMS/trunk/src/main/csharp/ Apache.NMS.MSMQ/trunk/src/main/csharp/ ...
Date Tue, 06 Oct 2009 23:53:13 GMT
Author: jgomes
Date: Tue Oct  6 23:53:12 2009
New Revision: 822538

URL: http://svn.apache.org/viewvc?rev=822538&view=rev
Log:
Added API method to ISession and IMessageProducer to create StreamMessage.
Added MSMQ and EMS provider implementations of StreamMessage.
Fixes [AMQNET-116]. (See https://issues.apache.org/activemq/browse/AMQNET-116)

Added:
    activemq/activemq-dotnet/Apache.NMS.EMS/trunk/src/main/csharp/StreamMessage.cs
      - copied, changed from r822525, activemq/activemq-dotnet/Apache.NMS.EMS/trunk/src/main/csharp/BytesMessage.cs
Modified:
    activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Commands/ActiveMQBytesMessage.cs
    activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Commands/ActiveMQStreamMessage.cs
    activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/MessageProducer.cs
    activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Session.cs
    activemq/activemq-dotnet/Apache.NMS.EMS/trunk/src/main/csharp/EMSConvert.cs
    activemq/activemq-dotnet/Apache.NMS.EMS/trunk/src/main/csharp/MessageProducer.cs
    activemq/activemq-dotnet/Apache.NMS.EMS/trunk/src/main/csharp/Session.cs
    activemq/activemq-dotnet/Apache.NMS.EMS/trunk/vs2008-ems.csproj
    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/MessageProducer.cs
    activemq/activemq-dotnet/Apache.NMS.MSMQ/trunk/src/main/csharp/ObjectMessage.cs
    activemq/activemq-dotnet/Apache.NMS.MSMQ/trunk/src/main/csharp/Session.cs
    activemq/activemq-dotnet/Apache.NMS.MSMQ/trunk/src/main/csharp/StreamMessage.cs
    activemq/activemq-dotnet/Apache.NMS.MSMQ/trunk/src/main/csharp/TextMessage.cs
    activemq/activemq-dotnet/Apache.NMS/trunk/src/main/csharp/IMessageProducer.cs
    activemq/activemq-dotnet/Apache.NMS/trunk/src/main/csharp/ISession.cs

Modified: activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Commands/ActiveMQBytesMessage.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Commands/ActiveMQBytesMessage.cs?rev=822538&r1=822537&r2=822538&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Commands/ActiveMQBytesMessage.cs (original)
+++ activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Commands/ActiveMQBytesMessage.cs Tue Oct  6 23:53:12 2009
@@ -23,482 +23,482 @@
 
 namespace Apache.NMS.ActiveMQ.Commands
 {
-    public class ActiveMQBytesMessage : ActiveMQMessage, IBytesMessage
-    {
-        public const byte ID_ACTIVEMQBYTESMESSAGE = 24;
-        
-        private EndianBinaryReader dataIn = null;
-        private EndianBinaryWriter dataOut = null;
-        private MemoryStream outputBuffer = null;
-        
-        // Need this later when we add compression to store true content length.
-        private long length = 0;
-
-        public override byte GetDataStructureType()
-        {
-            return ID_ACTIVEMQBYTESMESSAGE;
-        }
-
-        public override Object Clone()
-        {
-            StoreContent();
-            return base.Clone();
-        }
-
-        public override void OnSend()
-        {
-            base.OnSend();
-            StoreContent();                         
-        }
-        
-        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;
-            }
-        }
-            
-    }
+	public class ActiveMQBytesMessage : ActiveMQMessage, IBytesMessage
+	{
+		public const byte ID_ACTIVEMQBYTESMESSAGE = 24;
+
+		private EndianBinaryReader dataIn = null;
+		private EndianBinaryWriter dataOut = null;
+		private MemoryStream outputBuffer = null;
+
+		// Need this later when we add compression to store true content length.
+		private long length = 0;
+
+		public override byte GetDataStructureType()
+		{
+			return ID_ACTIVEMQBYTESMESSAGE;
+		}
+
+		public override Object Clone()
+		{
+			StoreContent();
+			return base.Clone();
+		}
+
+		public override void OnSend()
+		{
+			base.OnSend();
+			StoreContent();
+		}
+
+		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.ActiveMQ/trunk/src/main/csharp/Commands/ActiveMQStreamMessage.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Commands/ActiveMQStreamMessage.cs?rev=822538&r1=822537&r2=822538&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Commands/ActiveMQStreamMessage.cs (original)
+++ activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Commands/ActiveMQStreamMessage.cs Tue Oct  6 23:53:12 2009
@@ -24,894 +24,894 @@
 
 namespace Apache.NMS.ActiveMQ.Commands
 {
-    public class ActiveMQStreamMessage : ActiveMQMessage, IStreamMessage
-    {
-        private EndianBinaryReader dataIn = null;
-        private EndianBinaryWriter dataOut = null;
-        private MemoryStream byteBuffer = null;
-        private int bytesRemaining = -1;
-
-        public const byte ID_ACTIVEMQSTREAMMESSAGE = 27;
-
-        public override byte GetDataStructureType()
-        {
-            return ID_ACTIVEMQSTREAMMESSAGE;
-        }
-
-        public bool ReadBoolean()
-        {
-            InitializeReading();
-
-            try
-            {
-                long startingPos = this.byteBuffer.Position;
-                try
-                {
-                    int type = this.dataIn.ReadByte();
-                    
-                    if(type == PrimitiveMap.BOOLEAN_TYPE)
-                    {
-                        return this.dataIn.ReadBoolean();
-                    }
-                    else if(type == PrimitiveMap.STRING_TYPE)
-                    {
-                        return Boolean.Parse(this.dataIn.ReadString16());
-                    }
-                    else if(type == PrimitiveMap.NULL)
-                    {
-                        this.byteBuffer.Seek(startingPos, SeekOrigin.Begin);
-                        throw new NMSException("Cannot convert Null type to a bool");
-                    }
-                    else
-                    {
-                        this.byteBuffer.Seek(startingPos, SeekOrigin.Begin);
-                        throw new MessageFormatException("Value is not a Boolean type.");
-                    }
-                }
-                catch(FormatException e)
-                {
-                    this.byteBuffer.Seek(startingPos, SeekOrigin.Begin);
-                    throw NMSExceptionSupport.createMessageFormatException(e);
-                }
-            }
-            catch(EndOfStreamException e)
-            {
-                throw NMSExceptionSupport.createMessageEOFException(e);
-            }
-            catch(IOException e)
-            {
-                throw NMSExceptionSupport.createMessageFormatException(e);
-            }
-        }
-    
-        public byte ReadByte()
-        {
-            InitializeReading();
-            
-            try
-            {
-                long startingPos = this.byteBuffer.Position;
-                try
-                {
-                    int type = this.dataIn.ReadByte();
-                    
-                    if(type == PrimitiveMap.BYTE_TYPE)
-                    {
-                        return this.dataIn.ReadByte();
-                    }
-                    else if(type == PrimitiveMap.STRING_TYPE)
-                    {
-                        return Byte.Parse(this.dataIn.ReadString16());
-                    }
-                    else if(type == PrimitiveMap.NULL)
-                    {
-                        this.byteBuffer.Seek(startingPos, SeekOrigin.Begin);
-                        throw new NMSException("Cannot convert Null type to a byte");
-                    }
-                    else
-                    {
-                        this.byteBuffer.Seek(startingPos, SeekOrigin.Begin);
-                        throw new MessageFormatException("Value is not a Byte type.");
-                    }
-                }
-                catch(FormatException e)
-                {
-                    this.byteBuffer.Seek(startingPos, SeekOrigin.Begin);
-                    throw NMSExceptionSupport.createMessageFormatException(e);
-                }
-            }
-            catch(EndOfStreamException e)
-            {
-                throw NMSExceptionSupport.createMessageEOFException(e);
-            }
-            catch(IOException e)
-            {
-                throw NMSExceptionSupport.createMessageFormatException(e);
-            }            
-        }
-             
-        public char ReadChar()
-        {
-            InitializeReading();
-
-            try
-            {
-                long startingPos = this.byteBuffer.Position;
-                try
-                {
-                    int type = this.dataIn.ReadByte();
-                    
-                    if(type == PrimitiveMap.CHAR_TYPE)
-                    {
-                        return this.dataIn.ReadChar();
-                    }
-                    else if(type == PrimitiveMap.NULL)
-                    {
-                        this.byteBuffer.Seek(startingPos, SeekOrigin.Begin);
-                        throw new NMSException("Cannot convert Null type to a char");
-                    }
-                    else
-                    {
-                        this.byteBuffer.Seek(startingPos, SeekOrigin.Begin);
-                        throw new MessageFormatException("Value is not a Char type.");
-                    }
-                }
-                catch(FormatException e)
-                {
-                    this.byteBuffer.Seek(startingPos, SeekOrigin.Begin);
-                    throw NMSExceptionSupport.createMessageFormatException(e);
-                }
-            }
-            catch(EndOfStreamException e)
-            {
-                throw NMSExceptionSupport.createMessageEOFException(e);
-            }
-            catch(IOException e)
-            {
-                throw NMSExceptionSupport.createMessageFormatException(e);
-            }   
-        }
-   
-        public short ReadInt16()
-        {
-            InitializeReading();
-
-            try
-            {
-                long startingPos = this.byteBuffer.Position;
-                try
-                {
-                    int type = this.dataIn.ReadByte();
-
-                    if(type == PrimitiveMap.SHORT_TYPE)
-                    {
-                        return this.dataIn.ReadInt16();
-                    }
-                    else if(type == PrimitiveMap.BYTE_TYPE)
-                    {
-                        return this.dataIn.ReadByte();
-                    }
-                    else if(type == PrimitiveMap.STRING_TYPE)
-                    {
-                        return Int16.Parse(this.dataIn.ReadString16());
-                    }
-                    else if(type == PrimitiveMap.NULL)
-                    {
-                        this.byteBuffer.Seek(startingPos, SeekOrigin.Begin);
-                        throw new NMSException("Cannot convert Null type to a short");
-                    }
-                    else
-                    {
-                        this.byteBuffer.Seek(startingPos, SeekOrigin.Begin);
-                        throw new MessageFormatException("Value is not a Int16 type.");
-                    }
-                }
-                catch(FormatException e)
-                {
-                    this.byteBuffer.Seek(startingPos, SeekOrigin.Begin);
-                    throw NMSExceptionSupport.createMessageFormatException(e);
-                }
-            }
-            catch(EndOfStreamException e)
-            {
-                throw NMSExceptionSupport.createMessageEOFException(e);
-            }
-            catch(IOException e)
-            {
-                throw NMSExceptionSupport.createMessageFormatException(e);
-            }            
-        }
-     
-        public int ReadInt32()
-        {
-            InitializeReading();
-
-            try
-            {
-                long startingPos = this.byteBuffer.Position;
-                try
-                {
-                    int type = this.dataIn.ReadByte();
-
-                    if(type == PrimitiveMap.INTEGER_TYPE)
-                    {
-                        return this.dataIn.ReadInt32();
-                    }
-                    else if(type == PrimitiveMap.SHORT_TYPE)
-                    {
-                        return this.dataIn.ReadInt16();
-                    }
-                    else if(type == PrimitiveMap.BYTE_TYPE)
-                    {
-                        return this.dataIn.ReadByte();
-                    }
-                    else if(type == PrimitiveMap.STRING_TYPE)
-                    {
-                        return Int32.Parse(this.dataIn.ReadString16());
-                    }
-                    else if(type == PrimitiveMap.NULL)
-                    {
-                        this.byteBuffer.Seek(startingPos, SeekOrigin.Begin);
-                        throw new NMSException("Cannot convert Null type to a int");
-                    }
-                    else
-                    {
-                        this.byteBuffer.Seek(startingPos, SeekOrigin.Begin);
-                        throw new MessageFormatException("Value is not a Int32 type.");
-                    }
-                }
-                catch(FormatException e)
-                {
-                    this.byteBuffer.Seek(startingPos, SeekOrigin.Begin);
-                    throw NMSExceptionSupport.createMessageFormatException(e);
-                }
-            }
-            catch(EndOfStreamException e)
-            {
-                throw NMSExceptionSupport.createMessageEOFException(e);
-            }
-            catch(IOException e)
-            {
-                throw NMSExceptionSupport.createMessageFormatException(e);
-            }            
-        }
-
-        public long ReadInt64()
-        {
-            InitializeReading();
-
-            try
-            {
-                long startingPos = this.byteBuffer.Position;
-                try
-                {
-                    int type = this.dataIn.ReadByte();
-
-                    if(type == PrimitiveMap.LONG_TYPE)
-                    {
-                        return this.dataIn.ReadInt64();
-                    }
-                    else if(type == PrimitiveMap.INTEGER_TYPE)
-                    {
-                        return this.dataIn.ReadInt32();
-                    }
-                    else if(type == PrimitiveMap.SHORT_TYPE)
-                    {
-                        return this.dataIn.ReadInt16();
-                    }
-                    else if(type == PrimitiveMap.BYTE_TYPE)
-                    {
-                        return this.dataIn.ReadByte();
-                    }
-                    else if(type == PrimitiveMap.STRING_TYPE)
-                    {
-                        return Int64.Parse(this.dataIn.ReadString16());
-                    }
-                    else if(type == PrimitiveMap.NULL)
-                    {
-                        this.byteBuffer.Seek(startingPos, SeekOrigin.Begin);
-                        throw new NMSException("Cannot convert Null type to a long");
-                    }
-                    else
-                    {
-                        this.byteBuffer.Seek(startingPos, SeekOrigin.Begin);
-                        throw new MessageFormatException("Value is not a Int64 type.");
-                    }
-                }
-                catch(FormatException e)
-                {
-                    this.byteBuffer.Seek(startingPos, SeekOrigin.Begin);
-                    throw NMSExceptionSupport.createMessageFormatException(e);
-                }
-            }
-            catch(EndOfStreamException e)
-            {
-                throw NMSExceptionSupport.createMessageEOFException(e);
-            }
-            catch(IOException e)
-            {
-                throw NMSExceptionSupport.createMessageFormatException(e);
-            }            
-        }
-    
-        public float ReadSingle()
-        {
-            InitializeReading();
-
-            try
-            {
-                long startingPos = this.byteBuffer.Position;
-                try
-                {
-                    int type = this.dataIn.ReadByte();
-                    
-                    if(type == PrimitiveMap.FLOAT_TYPE)
-                    {
-                        return this.dataIn.ReadSingle();
-                    }
-                    else if(type == PrimitiveMap.STRING_TYPE)
-                    {
-                        return Single.Parse(this.dataIn.ReadString16());
-                    }
-                    else if(type == PrimitiveMap.NULL)
-                    {
-                        this.byteBuffer.Seek(startingPos, SeekOrigin.Begin);
-                        throw new NMSException("Cannot convert Null type to a float");
-                    }
-                    else
-                    {
-                        this.byteBuffer.Seek(startingPos, SeekOrigin.Begin);
-                        throw new MessageFormatException("Value is not a Single type.");
-                    }
-                }
-                catch(FormatException e)
-                {
-                    this.byteBuffer.Seek(startingPos, SeekOrigin.Begin);
-                    throw NMSExceptionSupport.createMessageFormatException(e);
-                }
-            }
-            catch(EndOfStreamException e)
-            {
-                throw NMSExceptionSupport.createMessageEOFException(e);
-            }
-            catch(IOException e)
-            {
-                throw NMSExceptionSupport.createMessageFormatException(e);
-            }   
-        }
-   
-        public double ReadDouble()
-        {
-            InitializeReading();
-
-            try
-            {
-                long startingPos = this.byteBuffer.Position;
-                try
-                {
-                    int type = this.dataIn.ReadByte();
-                    
-                    if(type == PrimitiveMap.DOUBLE_TYPE)
-                    {
-                        return this.dataIn.ReadDouble();
-                    }
-                    else if(type == PrimitiveMap.FLOAT_TYPE)
-                    {
-                        return this.dataIn.ReadSingle();
-                    }
-                    else if(type == PrimitiveMap.STRING_TYPE)
-                    {
-                        return Single.Parse(this.dataIn.ReadString16());
-                    }
-                    else if(type == PrimitiveMap.NULL)
-                    {
-                        this.byteBuffer.Seek(startingPos, SeekOrigin.Begin);
-                        throw new NMSException("Cannot convert Null type to a double");
-                    }
-                    else
-                    {
-                        this.byteBuffer.Seek(startingPos, SeekOrigin.Begin);
-                        throw new MessageFormatException("Value is not a Double type.");
-                    }
-                }
-                catch(FormatException e)
-                {
-                    this.byteBuffer.Seek(startingPos, SeekOrigin.Begin);
-                    throw NMSExceptionSupport.createMessageFormatException(e);
-                }
-            }
-            catch(EndOfStreamException e)
-            {
-                throw NMSExceptionSupport.createMessageEOFException(e);
-            }
-            catch(IOException e)
-            {
-                throw NMSExceptionSupport.createMessageFormatException(e);
-            }   
-        }
-   
-        public string ReadString()
-        {
-            InitializeReading();
-
-            long startingPos = this.byteBuffer.Position;
-
-            try
-            {
-                int type = this.dataIn.ReadByte();
-                
-                if(type == PrimitiveMap.BIG_STRING_TYPE)
-                {
-                    return this.dataIn.ReadString32();
-                }
-                else if(type == PrimitiveMap.STRING_TYPE)
-                {
-                    return this.dataIn.ReadString16();
-                }
-                else if(type == PrimitiveMap.LONG_TYPE)
-                {
-                    return this.dataIn.ReadInt64().ToString();
-                }
-                else if(type == PrimitiveMap.INTEGER_TYPE)
-                {
-                    return this.dataIn.ReadInt32().ToString();
-                }
-                else if(type == PrimitiveMap.SHORT_TYPE)
-                {
-                    return this.dataIn.ReadInt16().ToString();
-                }
-                else if(type == PrimitiveMap.FLOAT_TYPE)
-                {
-                    return this.dataIn.ReadSingle().ToString();
-                }
-                else if(type == PrimitiveMap.DOUBLE_TYPE)
-                {
-                    return this.dataIn.ReadDouble().ToString();
-                }
-                else if(type == PrimitiveMap.CHAR_TYPE)
-                {
-                    return this.dataIn.ReadChar().ToString();
-                }
-                else if(type == PrimitiveMap.BYTE_TYPE)
-                {
-                    return this.dataIn.ReadByte().ToString();
-                }
-                else if(type == PrimitiveMap.BOOLEAN_TYPE)
-                {
-                    return this.dataIn.ReadBoolean().ToString();
-                }
-                else if(type == PrimitiveMap.NULL)
-                {
-                    return null;
-                }
-                else
-                {
-                    this.byteBuffer.Seek(startingPos, SeekOrigin.Begin);
-                    throw new MessageFormatException("Value is not a known type.");
-                }
-            }
-            catch(FormatException e)
-            {
-                this.byteBuffer.Seek(startingPos, SeekOrigin.Begin);
-                throw NMSExceptionSupport.createMessageFormatException(e);
-            }
-            catch(EndOfStreamException e)
-            {
-                throw NMSExceptionSupport.createMessageEOFException(e);
-            }
-            catch(IOException e)
-            {
-                throw NMSExceptionSupport.createMessageFormatException(e);
-            }
-        }
-
-        public int ReadBytes(byte[] value)
-        {
-            InitializeReading();
-            
-            if(value == null)
-            {
-                throw new NullReferenceException("Passed Byte Array is null");
-            }
-            
-            try
-            {
-                if(this.bytesRemaining == -1)
-                {
-                    long startingPos = this.byteBuffer.Position;
-                    byte type = this.dataIn.ReadByte();
-                    
-                    if(type != PrimitiveMap.BYTE_ARRAY_TYPE) 
-                    {
-                        this.byteBuffer.Seek(startingPos, SeekOrigin.Begin);
-                        throw new MessageFormatException("Not a byte array");
-                    }
-                    
-                    this.bytesRemaining = this.dataIn.ReadInt32();
-                } 
-                else if(this.bytesRemaining == 0) 
-                {
-                    this.bytesRemaining = -1;
-                    return -1;
-                }
-    
-                if(value.Length <= this.bytesRemaining) 
-                {
-                    // small buffer
-                    this.bytesRemaining -= value.Length;
-                    this.dataIn.Read(value, 0, value.Length);
-                    return value.Length;
-                }
-                else
-                {
-                    // big buffer
-                    int rc = this.dataIn.Read(value, 0, this.bytesRemaining);
-                    this.bytesRemaining = 0;
-                    return rc;
-                }
-            } 
-            catch(EndOfStreamException ex)
-            {
-                throw NMSExceptionSupport.createMessageEOFException(ex);
-            } 
-            catch(IOException ex) 
-            {
-                throw NMSExceptionSupport.createMessageFormatException(ex);
-            }
-        }
-        
-        public Object ReadObject()
-        {
-            InitializeReading();
-
-            long startingPos = this.byteBuffer.Position;
-
-            try
-            {
-                int type = this.dataIn.ReadByte();
-                
-                if(type == PrimitiveMap.BIG_STRING_TYPE)
-                {
-                    return this.dataIn.ReadString32();
-                }
-                else if(type == PrimitiveMap.STRING_TYPE)
-                {
-                    return this.dataIn.ReadString16();
-                }
-                else if(type == PrimitiveMap.LONG_TYPE)
-                {
-                    return this.dataIn.ReadInt64();
-                }
-                else if(type == PrimitiveMap.INTEGER_TYPE)
-                {
-                    return this.dataIn.ReadInt32();
-                }
-                else if(type == PrimitiveMap.SHORT_TYPE)
-                {
-                    return this.dataIn.ReadInt16();
-                }
-                else if(type == PrimitiveMap.FLOAT_TYPE)
-                {
-                    return this.dataIn.ReadSingle();
-                }
-                else if(type == PrimitiveMap.DOUBLE_TYPE)
-                {
-                    return this.dataIn.ReadDouble();
-                }
-                else if(type == PrimitiveMap.CHAR_TYPE)
-                {
-                    return this.dataIn.ReadChar();
-                }
-                else if(type == PrimitiveMap.BYTE_TYPE)
-                {
-                    return this.dataIn.ReadByte();
-                }
-                else if(type == PrimitiveMap.BOOLEAN_TYPE)
-                {
-                    return this.dataIn.ReadBoolean();
-                }
-                else if(type == PrimitiveMap.BYTE_ARRAY_TYPE)
-                {
-                    int length = this.dataIn.ReadInt32();
-                    byte[] data = new byte[length];
-                    this.dataIn.Read(data, 0, length);
-                    return data;
-                }
-                else if(type == PrimitiveMap.NULL)
-                {
-                    return null;
-                }
-                else
-                {
-                    this.byteBuffer.Seek(startingPos, SeekOrigin.Begin);
-                    throw new MessageFormatException("Value is not a known type.");
-                }
-            }
-            catch(FormatException e)
-            {
-                this.byteBuffer.Seek(startingPos, SeekOrigin.Begin);
-                throw NMSExceptionSupport.createMessageFormatException(e);
-            }
-            catch(EndOfStreamException e)
-            {
-                throw NMSExceptionSupport.createMessageEOFException(e);
-            }
-            catch(IOException e)
-            {
-                throw NMSExceptionSupport.createMessageFormatException(e);
-            }
-        }
-
-        public void WriteBoolean(bool value)
-        {
-            InitializeWriting();
-            try
-            {
-                this.dataOut.Write(PrimitiveMap.BOOLEAN_TYPE);
-                this.dataOut.Write(value);
-            }
-            catch(IOException e)
-            {
-                NMSExceptionSupport.create(e);
-            }
-        }
-
-        public void WriteByte(byte value)
-        {
-            InitializeWriting();
-            try
-            {
-                this.dataOut.Write(PrimitiveMap.BYTE_TYPE);
-                this.dataOut.Write(value);
-            }
-            catch(IOException e)
-            {
-                NMSExceptionSupport.create(e);
-            }
-        }
-
-        public void WriteBytes(byte[] value)
-        {
-            InitializeWriting();
-            this.WriteBytes(value, 0, value.Length);
-        }
-
-        public void WriteBytes(byte[] value, int offset, int length)
-        {
-            InitializeWriting();
-            try
-            {
-                this.dataOut.Write(PrimitiveMap.BYTE_ARRAY_TYPE);
-                this.dataOut.Write((int) length);
-                this.dataOut.Write(value, offset, length);
-            }
-            catch(IOException e)
-            {
-                NMSExceptionSupport.create(e);
-            }
-        }
-
-        public void WriteChar(char value)
-        {
-            InitializeWriting();
-            try
-            {
-                this.dataOut.Write(PrimitiveMap.CHAR_TYPE);
-                this.dataOut.Write(value);
-            }
-            catch(IOException e)
-            {
-                NMSExceptionSupport.create(e);
-            }
-        }
-
-        public void WriteInt16(short value)
-        {
-            InitializeWriting();
-            try
-            {
-                this.dataOut.Write(PrimitiveMap.SHORT_TYPE);
-                this.dataOut.Write(value);
-            }
-            catch(IOException e)
-            {
-                NMSExceptionSupport.create(e);
-            }
-        }
-
-        public void WriteInt32(int value)
-        {
-            InitializeWriting();
-            try
-            {
-                this.dataOut.Write(PrimitiveMap.INTEGER_TYPE);
-                this.dataOut.Write(value);
-            }
-            catch(IOException e)
-            {
-                NMSExceptionSupport.create(e);
-            }
-        }
-
-        public void WriteInt64(long value)
-        {
-            InitializeWriting();
-            try
-            {
-                this.dataOut.Write(PrimitiveMap.LONG_TYPE);
-                this.dataOut.Write(value);
-            }
-            catch(IOException e)
-            {
-                NMSExceptionSupport.create(e);
-            }
-        }
-
-        public void WriteSingle(float value)
-        {
-            InitializeWriting();
-            try
-            {
-                this.dataOut.Write(PrimitiveMap.FLOAT_TYPE);
-                this.dataOut.Write(value);
-            }
-            catch(IOException e)
-            {
-                NMSExceptionSupport.create(e);
-            }
-        }
-
-        public void WriteDouble(double value)
-        {
-            InitializeWriting();
-            try
-            {
-                this.dataOut.Write(PrimitiveMap.DOUBLE_TYPE);
-                this.dataOut.Write(value);
-            }
-            catch(IOException e)
-            {
-                NMSExceptionSupport.create(e);
-            }
-        }
-        
-        public void WriteString(string value)
-        {
-            InitializeWriting();
-            try
-            {
-                if( value.Length > 8192 )
-                {
-                    this.dataOut.Write(PrimitiveMap.BIG_STRING_TYPE);
-                    this.dataOut.WriteString32(value);
-                }
-                else
-                {
-                    this.dataOut.Write(PrimitiveMap.STRING_TYPE);
-                    this.dataOut.WriteString16(value);
-                }
-            }
-            catch(IOException e)
-            {
-                NMSExceptionSupport.create(e);
-            }
-        }
-        
-        public void WriteObject(Object value)
-        {            
-            InitializeWriting();
-            if( value is System.Byte )
-            {
-                this.WriteByte( (byte) value );
-            }
-            else if( value is Char )
-            {
-                this.WriteChar( (char) value );
-            }
-            else if( value is Boolean )
-            {
-                this.WriteBoolean( (bool) value );
-            }
-            else if( value is Int16 )
-            {
-                this.WriteInt16( (short) value );
-            }
-            else if( value is Int32 )
-            {
-                this.WriteInt32( (int) value );
-            }
-            else if( value is Int64 )
-            {
-                this.WriteInt64( (long) value );
-            }
-            else if( value is Single )
-            {
-                this.WriteSingle( (float) value );
-            }
-            else if( value is Double )
-            {
-                this.WriteDouble( (double) value );
-            }
-            else if( value is byte[] )
-            {
-                this.WriteBytes( (byte[]) value );
-            }
-            else if( value is String )
-            {
-                this.WriteString( (string) value );
-            }
-            else
-            {
-                throw new MessageFormatException("Cannot write non-primitive type:" + value.GetType());
-            }
-        }
-
-        public override Object Clone()
-        {
-            StoreContent();
-            return base.Clone();
-        }
-
-        public override void OnSend()
-        {
-            base.OnSend();
-            StoreContent();                         
-        }
-        
-        public override void ClearBody()
-        {
-            base.ClearBody();
-            this.byteBuffer = null;
-            this.dataIn = null;
-            this.dataOut = null;
-            this.bytesRemaining = -1;
-        }
-
-        public void Reset()
-        {
-            StoreContent();
-            this.dataIn = null;
-            this.dataOut = null;
-            this.byteBuffer = null;
-            this.bytesRemaining = -1;
-            this.ReadOnlyBody = true;        
-        }
-        
-        private void InitializeReading() 
-        {
-            FailIfWriteOnlyBody();
-            if(this.dataIn == null)
-            {
-                // TODO - Add support for Message Compression.
-                this.byteBuffer = new MemoryStream(this.Content, false);
-                dataIn = new EndianBinaryReader(byteBuffer);
-            }
-        }
-        
-        private void InitializeWriting()
-        {
-            FailIfReadOnlyBody();
-            if(this.dataOut == null) 
-            {
-                // TODO - Add support for Message Compression.
-                this.byteBuffer = new MemoryStream();
-                this.dataOut = new EndianBinaryWriter(byteBuffer);
-            }
-        }
-        
-        private void StoreContent()
-        {
-            if( dataOut != null)
-            {
-                dataOut.Close();
-                // TODO - Add support for Message Compression.
-
-                this.Content = byteBuffer.ToArray();
-                this.dataOut = null;
-                this.byteBuffer = null;
-            }
-        }
-        
-    }
+	public class ActiveMQStreamMessage : ActiveMQMessage, IStreamMessage
+	{
+		private EndianBinaryReader dataIn = null;
+		private EndianBinaryWriter dataOut = null;
+		private MemoryStream byteBuffer = null;
+		private int bytesRemaining = -1;
+
+		public const byte ID_ACTIVEMQSTREAMMESSAGE = 27;
+
+		public override byte GetDataStructureType()
+		{
+			return ID_ACTIVEMQSTREAMMESSAGE;
+		}
+
+		public bool ReadBoolean()
+		{
+			InitializeReading();
+
+			try
+			{
+				long startingPos = this.byteBuffer.Position;
+				try
+				{
+					int type = this.dataIn.ReadByte();
+
+					if(type == PrimitiveMap.BOOLEAN_TYPE)
+					{
+						return this.dataIn.ReadBoolean();
+					}
+					else if(type == PrimitiveMap.STRING_TYPE)
+					{
+						return Boolean.Parse(this.dataIn.ReadString16());
+					}
+					else if(type == PrimitiveMap.NULL)
+					{
+						this.byteBuffer.Seek(startingPos, SeekOrigin.Begin);
+						throw new NMSException("Cannot convert Null type to a bool");
+					}
+					else
+					{
+						this.byteBuffer.Seek(startingPos, SeekOrigin.Begin);
+						throw new MessageFormatException("Value is not a Boolean type.");
+					}
+				}
+				catch(FormatException e)
+				{
+					this.byteBuffer.Seek(startingPos, SeekOrigin.Begin);
+					throw NMSExceptionSupport.createMessageFormatException(e);
+				}
+			}
+			catch(EndOfStreamException e)
+			{
+				throw NMSExceptionSupport.createMessageEOFException(e);
+			}
+			catch(IOException e)
+			{
+				throw NMSExceptionSupport.createMessageFormatException(e);
+			}
+		}
+
+		public byte ReadByte()
+		{
+			InitializeReading();
+
+			try
+			{
+				long startingPos = this.byteBuffer.Position;
+				try
+				{
+					int type = this.dataIn.ReadByte();
+
+					if(type == PrimitiveMap.BYTE_TYPE)
+					{
+						return this.dataIn.ReadByte();
+					}
+					else if(type == PrimitiveMap.STRING_TYPE)
+					{
+						return Byte.Parse(this.dataIn.ReadString16());
+					}
+					else if(type == PrimitiveMap.NULL)
+					{
+						this.byteBuffer.Seek(startingPos, SeekOrigin.Begin);
+						throw new NMSException("Cannot convert Null type to a byte");
+					}
+					else
+					{
+						this.byteBuffer.Seek(startingPos, SeekOrigin.Begin);
+						throw new MessageFormatException("Value is not a Byte type.");
+					}
+				}
+				catch(FormatException e)
+				{
+					this.byteBuffer.Seek(startingPos, SeekOrigin.Begin);
+					throw NMSExceptionSupport.createMessageFormatException(e);
+				}
+			}
+			catch(EndOfStreamException e)
+			{
+				throw NMSExceptionSupport.createMessageEOFException(e);
+			}
+			catch(IOException e)
+			{
+				throw NMSExceptionSupport.createMessageFormatException(e);
+			}
+		}
+
+		public char ReadChar()
+		{
+			InitializeReading();
+
+			try
+			{
+				long startingPos = this.byteBuffer.Position;
+				try
+				{
+					int type = this.dataIn.ReadByte();
+
+					if(type == PrimitiveMap.CHAR_TYPE)
+					{
+						return this.dataIn.ReadChar();
+					}
+					else if(type == PrimitiveMap.NULL)
+					{
+						this.byteBuffer.Seek(startingPos, SeekOrigin.Begin);
+						throw new NMSException("Cannot convert Null type to a char");
+					}
+					else
+					{
+						this.byteBuffer.Seek(startingPos, SeekOrigin.Begin);
+						throw new MessageFormatException("Value is not a Char type.");
+					}
+				}
+				catch(FormatException e)
+				{
+					this.byteBuffer.Seek(startingPos, SeekOrigin.Begin);
+					throw NMSExceptionSupport.createMessageFormatException(e);
+				}
+			}
+			catch(EndOfStreamException e)
+			{
+				throw NMSExceptionSupport.createMessageEOFException(e);
+			}
+			catch(IOException e)
+			{
+				throw NMSExceptionSupport.createMessageFormatException(e);
+			}
+		}
+
+		public short ReadInt16()
+		{
+			InitializeReading();
+
+			try
+			{
+				long startingPos = this.byteBuffer.Position;
+				try
+				{
+					int type = this.dataIn.ReadByte();
+
+					if(type == PrimitiveMap.SHORT_TYPE)
+					{
+						return this.dataIn.ReadInt16();
+					}
+					else if(type == PrimitiveMap.BYTE_TYPE)
+					{
+						return this.dataIn.ReadByte();
+					}
+					else if(type == PrimitiveMap.STRING_TYPE)
+					{
+						return Int16.Parse(this.dataIn.ReadString16());
+					}
+					else if(type == PrimitiveMap.NULL)
+					{
+						this.byteBuffer.Seek(startingPos, SeekOrigin.Begin);
+						throw new NMSException("Cannot convert Null type to a short");
+					}
+					else
+					{
+						this.byteBuffer.Seek(startingPos, SeekOrigin.Begin);
+						throw new MessageFormatException("Value is not a Int16 type.");
+					}
+				}
+				catch(FormatException e)
+				{
+					this.byteBuffer.Seek(startingPos, SeekOrigin.Begin);
+					throw NMSExceptionSupport.createMessageFormatException(e);
+				}
+			}
+			catch(EndOfStreamException e)
+			{
+				throw NMSExceptionSupport.createMessageEOFException(e);
+			}
+			catch(IOException e)
+			{
+				throw NMSExceptionSupport.createMessageFormatException(e);
+			}
+		}
+
+		public int ReadInt32()
+		{
+			InitializeReading();
+
+			try
+			{
+				long startingPos = this.byteBuffer.Position;
+				try
+				{
+					int type = this.dataIn.ReadByte();
+
+					if(type == PrimitiveMap.INTEGER_TYPE)
+					{
+						return this.dataIn.ReadInt32();
+					}
+					else if(type == PrimitiveMap.SHORT_TYPE)
+					{
+						return this.dataIn.ReadInt16();
+					}
+					else if(type == PrimitiveMap.BYTE_TYPE)
+					{
+						return this.dataIn.ReadByte();
+					}
+					else if(type == PrimitiveMap.STRING_TYPE)
+					{
+						return Int32.Parse(this.dataIn.ReadString16());
+					}
+					else if(type == PrimitiveMap.NULL)
+					{
+						this.byteBuffer.Seek(startingPos, SeekOrigin.Begin);
+						throw new NMSException("Cannot convert Null type to a int");
+					}
+					else
+					{
+						this.byteBuffer.Seek(startingPos, SeekOrigin.Begin);
+						throw new MessageFormatException("Value is not a Int32 type.");
+					}
+				}
+				catch(FormatException e)
+				{
+					this.byteBuffer.Seek(startingPos, SeekOrigin.Begin);
+					throw NMSExceptionSupport.createMessageFormatException(e);
+				}
+			}
+			catch(EndOfStreamException e)
+			{
+				throw NMSExceptionSupport.createMessageEOFException(e);
+			}
+			catch(IOException e)
+			{
+				throw NMSExceptionSupport.createMessageFormatException(e);
+			}
+		}
+
+		public long ReadInt64()
+		{
+			InitializeReading();
+
+			try
+			{
+				long startingPos = this.byteBuffer.Position;
+				try
+				{
+					int type = this.dataIn.ReadByte();
+
+					if(type == PrimitiveMap.LONG_TYPE)
+					{
+						return this.dataIn.ReadInt64();
+					}
+					else if(type == PrimitiveMap.INTEGER_TYPE)
+					{
+						return this.dataIn.ReadInt32();
+					}
+					else if(type == PrimitiveMap.SHORT_TYPE)
+					{
+						return this.dataIn.ReadInt16();
+					}
+					else if(type == PrimitiveMap.BYTE_TYPE)
+					{
+						return this.dataIn.ReadByte();
+					}
+					else if(type == PrimitiveMap.STRING_TYPE)
+					{
+						return Int64.Parse(this.dataIn.ReadString16());
+					}
+					else if(type == PrimitiveMap.NULL)
+					{
+						this.byteBuffer.Seek(startingPos, SeekOrigin.Begin);
+						throw new NMSException("Cannot convert Null type to a long");
+					}
+					else
+					{
+						this.byteBuffer.Seek(startingPos, SeekOrigin.Begin);
+						throw new MessageFormatException("Value is not a Int64 type.");
+					}
+				}
+				catch(FormatException e)
+				{
+					this.byteBuffer.Seek(startingPos, SeekOrigin.Begin);
+					throw NMSExceptionSupport.createMessageFormatException(e);
+				}
+			}
+			catch(EndOfStreamException e)
+			{
+				throw NMSExceptionSupport.createMessageEOFException(e);
+			}
+			catch(IOException e)
+			{
+				throw NMSExceptionSupport.createMessageFormatException(e);
+			}
+		}
+
+		public float ReadSingle()
+		{
+			InitializeReading();
+
+			try
+			{
+				long startingPos = this.byteBuffer.Position;
+				try
+				{
+					int type = this.dataIn.ReadByte();
+
+					if(type == PrimitiveMap.FLOAT_TYPE)
+					{
+						return this.dataIn.ReadSingle();
+					}
+					else if(type == PrimitiveMap.STRING_TYPE)
+					{
+						return Single.Parse(this.dataIn.ReadString16());
+					}
+					else if(type == PrimitiveMap.NULL)
+					{
+						this.byteBuffer.Seek(startingPos, SeekOrigin.Begin);
+						throw new NMSException("Cannot convert Null type to a float");
+					}
+					else
+					{
+						this.byteBuffer.Seek(startingPos, SeekOrigin.Begin);
+						throw new MessageFormatException("Value is not a Single type.");
+					}
+				}
+				catch(FormatException e)
+				{
+					this.byteBuffer.Seek(startingPos, SeekOrigin.Begin);
+					throw NMSExceptionSupport.createMessageFormatException(e);
+				}
+			}
+			catch(EndOfStreamException e)
+			{
+				throw NMSExceptionSupport.createMessageEOFException(e);
+			}
+			catch(IOException e)
+			{
+				throw NMSExceptionSupport.createMessageFormatException(e);
+			}
+		}
+
+		public double ReadDouble()
+		{
+			InitializeReading();
+
+			try
+			{
+				long startingPos = this.byteBuffer.Position;
+				try
+				{
+					int type = this.dataIn.ReadByte();
+
+					if(type == PrimitiveMap.DOUBLE_TYPE)
+					{
+						return this.dataIn.ReadDouble();
+					}
+					else if(type == PrimitiveMap.FLOAT_TYPE)
+					{
+						return this.dataIn.ReadSingle();
+					}
+					else if(type == PrimitiveMap.STRING_TYPE)
+					{
+						return Single.Parse(this.dataIn.ReadString16());
+					}
+					else if(type == PrimitiveMap.NULL)
+					{
+						this.byteBuffer.Seek(startingPos, SeekOrigin.Begin);
+						throw new NMSException("Cannot convert Null type to a double");
+					}
+					else
+					{
+						this.byteBuffer.Seek(startingPos, SeekOrigin.Begin);
+						throw new MessageFormatException("Value is not a Double type.");
+					}
+				}
+				catch(FormatException e)
+				{
+					this.byteBuffer.Seek(startingPos, SeekOrigin.Begin);
+					throw NMSExceptionSupport.createMessageFormatException(e);
+				}
+			}
+			catch(EndOfStreamException e)
+			{
+				throw NMSExceptionSupport.createMessageEOFException(e);
+			}
+			catch(IOException e)
+			{
+				throw NMSExceptionSupport.createMessageFormatException(e);
+			}
+		}
+
+		public string ReadString()
+		{
+			InitializeReading();
+
+			long startingPos = this.byteBuffer.Position;
+
+			try
+			{
+				int type = this.dataIn.ReadByte();
+
+				if(type == PrimitiveMap.BIG_STRING_TYPE)
+				{
+					return this.dataIn.ReadString32();
+				}
+				else if(type == PrimitiveMap.STRING_TYPE)
+				{
+					return this.dataIn.ReadString16();
+				}
+				else if(type == PrimitiveMap.LONG_TYPE)
+				{
+					return this.dataIn.ReadInt64().ToString();
+				}
+				else if(type == PrimitiveMap.INTEGER_TYPE)
+				{
+					return this.dataIn.ReadInt32().ToString();
+				}
+				else if(type == PrimitiveMap.SHORT_TYPE)
+				{
+					return this.dataIn.ReadInt16().ToString();
+				}
+				else if(type == PrimitiveMap.FLOAT_TYPE)
+				{
+					return this.dataIn.ReadSingle().ToString();
+				}
+				else if(type == PrimitiveMap.DOUBLE_TYPE)
+				{
+					return this.dataIn.ReadDouble().ToString();
+				}
+				else if(type == PrimitiveMap.CHAR_TYPE)
+				{
+					return this.dataIn.ReadChar().ToString();
+				}
+				else if(type == PrimitiveMap.BYTE_TYPE)
+				{
+					return this.dataIn.ReadByte().ToString();
+				}
+				else if(type == PrimitiveMap.BOOLEAN_TYPE)
+				{
+					return this.dataIn.ReadBoolean().ToString();
+				}
+				else if(type == PrimitiveMap.NULL)
+				{
+					return null;
+				}
+				else
+				{
+					this.byteBuffer.Seek(startingPos, SeekOrigin.Begin);
+					throw new MessageFormatException("Value is not a known type.");
+				}
+			}
+			catch(FormatException e)
+			{
+				this.byteBuffer.Seek(startingPos, SeekOrigin.Begin);
+				throw NMSExceptionSupport.createMessageFormatException(e);
+			}
+			catch(EndOfStreamException e)
+			{
+				throw NMSExceptionSupport.createMessageEOFException(e);
+			}
+			catch(IOException e)
+			{
+				throw NMSExceptionSupport.createMessageFormatException(e);
+			}
+		}
+
+		public int ReadBytes(byte[] value)
+		{
+			InitializeReading();
+
+			if(value == null)
+			{
+				throw new NullReferenceException("Passed Byte Array is null");
+			}
+
+			try
+			{
+				if(this.bytesRemaining == -1)
+				{
+					long startingPos = this.byteBuffer.Position;
+					byte type = this.dataIn.ReadByte();
+
+					if(type != PrimitiveMap.BYTE_ARRAY_TYPE)
+					{
+						this.byteBuffer.Seek(startingPos, SeekOrigin.Begin);
+						throw new MessageFormatException("Not a byte array");
+					}
+
+					this.bytesRemaining = this.dataIn.ReadInt32();
+				}
+				else if(this.bytesRemaining == 0)
+				{
+					this.bytesRemaining = -1;
+					return -1;
+				}
+
+				if(value.Length <= this.bytesRemaining)
+				{
+					// small buffer
+					this.bytesRemaining -= value.Length;
+					this.dataIn.Read(value, 0, value.Length);
+					return value.Length;
+				}
+				else
+				{
+					// big buffer
+					int rc = this.dataIn.Read(value, 0, this.bytesRemaining);
+					this.bytesRemaining = 0;
+					return rc;
+				}
+			}
+			catch(EndOfStreamException ex)
+			{
+				throw NMSExceptionSupport.createMessageEOFException(ex);
+			}
+			catch(IOException ex)
+			{
+				throw NMSExceptionSupport.createMessageFormatException(ex);
+			}
+		}
+
+		public Object ReadObject()
+		{
+			InitializeReading();
+
+			long startingPos = this.byteBuffer.Position;
+
+			try
+			{
+				int type = this.dataIn.ReadByte();
+
+				if(type == PrimitiveMap.BIG_STRING_TYPE)
+				{
+					return this.dataIn.ReadString32();
+				}
+				else if(type == PrimitiveMap.STRING_TYPE)
+				{
+					return this.dataIn.ReadString16();
+				}
+				else if(type == PrimitiveMap.LONG_TYPE)
+				{
+					return this.dataIn.ReadInt64();
+				}
+				else if(type == PrimitiveMap.INTEGER_TYPE)
+				{
+					return this.dataIn.ReadInt32();
+				}
+				else if(type == PrimitiveMap.SHORT_TYPE)
+				{
+					return this.dataIn.ReadInt16();
+				}
+				else if(type == PrimitiveMap.FLOAT_TYPE)
+				{
+					return this.dataIn.ReadSingle();
+				}
+				else if(type == PrimitiveMap.DOUBLE_TYPE)
+				{
+					return this.dataIn.ReadDouble();
+				}
+				else if(type == PrimitiveMap.CHAR_TYPE)
+				{
+					return this.dataIn.ReadChar();
+				}
+				else if(type == PrimitiveMap.BYTE_TYPE)
+				{
+					return this.dataIn.ReadByte();
+				}
+				else if(type == PrimitiveMap.BOOLEAN_TYPE)
+				{
+					return this.dataIn.ReadBoolean();
+				}
+				else if(type == PrimitiveMap.BYTE_ARRAY_TYPE)
+				{
+					int length = this.dataIn.ReadInt32();
+					byte[] data = new byte[length];
+					this.dataIn.Read(data, 0, length);
+					return data;
+				}
+				else if(type == PrimitiveMap.NULL)
+				{
+					return null;
+				}
+				else
+				{
+					this.byteBuffer.Seek(startingPos, SeekOrigin.Begin);
+					throw new MessageFormatException("Value is not a known type.");
+				}
+			}
+			catch(FormatException e)
+			{
+				this.byteBuffer.Seek(startingPos, SeekOrigin.Begin);
+				throw NMSExceptionSupport.createMessageFormatException(e);
+			}
+			catch(EndOfStreamException e)
+			{
+				throw NMSExceptionSupport.createMessageEOFException(e);
+			}
+			catch(IOException e)
+			{
+				throw NMSExceptionSupport.createMessageFormatException(e);
+			}
+		}
+
+		public void WriteBoolean(bool value)
+		{
+			InitializeWriting();
+			try
+			{
+				this.dataOut.Write(PrimitiveMap.BOOLEAN_TYPE);
+				this.dataOut.Write(value);
+			}
+			catch(IOException e)
+			{
+				NMSExceptionSupport.create(e);
+			}
+		}
+
+		public void WriteByte(byte value)
+		{
+			InitializeWriting();
+			try
+			{
+				this.dataOut.Write(PrimitiveMap.BYTE_TYPE);
+				this.dataOut.Write(value);
+			}
+			catch(IOException e)
+			{
+				NMSExceptionSupport.create(e);
+			}
+		}
+
+		public void WriteBytes(byte[] value)
+		{
+			InitializeWriting();
+			this.WriteBytes(value, 0, value.Length);
+		}
+
+		public void WriteBytes(byte[] value, int offset, int length)
+		{
+			InitializeWriting();
+			try
+			{
+				this.dataOut.Write(PrimitiveMap.BYTE_ARRAY_TYPE);
+				this.dataOut.Write((int) length);
+				this.dataOut.Write(value, offset, length);
+			}
+			catch(IOException e)
+			{
+				NMSExceptionSupport.create(e);
+			}
+		}
+
+		public void WriteChar(char value)
+		{
+			InitializeWriting();
+			try
+			{
+				this.dataOut.Write(PrimitiveMap.CHAR_TYPE);
+				this.dataOut.Write(value);
+			}
+			catch(IOException e)
+			{
+				NMSExceptionSupport.create(e);
+			}
+		}
+
+		public void WriteInt16(short value)
+		{
+			InitializeWriting();
+			try
+			{
+				this.dataOut.Write(PrimitiveMap.SHORT_TYPE);
+				this.dataOut.Write(value);
+			}
+			catch(IOException e)
+			{
+				NMSExceptionSupport.create(e);
+			}
+		}
+
+		public void WriteInt32(int value)
+		{
+			InitializeWriting();
+			try
+			{
+				this.dataOut.Write(PrimitiveMap.INTEGER_TYPE);
+				this.dataOut.Write(value);
+			}
+			catch(IOException e)
+			{
+				NMSExceptionSupport.create(e);
+			}
+		}
+
+		public void WriteInt64(long value)
+		{
+			InitializeWriting();
+			try
+			{
+				this.dataOut.Write(PrimitiveMap.LONG_TYPE);
+				this.dataOut.Write(value);
+			}
+			catch(IOException e)
+			{
+				NMSExceptionSupport.create(e);
+			}
+		}
+
+		public void WriteSingle(float value)
+		{
+			InitializeWriting();
+			try
+			{
+				this.dataOut.Write(PrimitiveMap.FLOAT_TYPE);
+				this.dataOut.Write(value);
+			}
+			catch(IOException e)
+			{
+				NMSExceptionSupport.create(e);
+			}
+		}
+
+		public void WriteDouble(double value)
+		{
+			InitializeWriting();
+			try
+			{
+				this.dataOut.Write(PrimitiveMap.DOUBLE_TYPE);
+				this.dataOut.Write(value);
+			}
+			catch(IOException e)
+			{
+				NMSExceptionSupport.create(e);
+			}
+		}
+
+		public void WriteString(string value)
+		{
+			InitializeWriting();
+			try
+			{
+				if( value.Length > 8192 )
+				{
+					this.dataOut.Write(PrimitiveMap.BIG_STRING_TYPE);
+					this.dataOut.WriteString32(value);
+				}
+				else
+				{
+					this.dataOut.Write(PrimitiveMap.STRING_TYPE);
+					this.dataOut.WriteString16(value);
+				}
+			}
+			catch(IOException e)
+			{
+				NMSExceptionSupport.create(e);
+			}
+		}
+
+		public void WriteObject(Object value)
+		{
+			InitializeWriting();
+			if( value is System.Byte )
+			{
+				this.WriteByte( (byte) value );
+			}
+			else if( value is Char )
+			{
+				this.WriteChar( (char) value );
+			}
+			else if( value is Boolean )
+			{
+				this.WriteBoolean( (bool) value );
+			}
+			else if( value is Int16 )
+			{
+				this.WriteInt16( (short) value );
+			}
+			else if( value is Int32 )
+			{
+				this.WriteInt32( (int) value );
+			}
+			else if( value is Int64 )
+			{
+				this.WriteInt64( (long) value );
+			}
+			else if( value is Single )
+			{
+				this.WriteSingle( (float) value );
+			}
+			else if( value is Double )
+			{
+				this.WriteDouble( (double) value );
+			}
+			else if( value is byte[] )
+			{
+				this.WriteBytes( (byte[]) value );
+			}
+			else if( value is String )
+			{
+				this.WriteString( (string) value );
+			}
+			else
+			{
+				throw new MessageFormatException("Cannot write non-primitive type:" + value.GetType());
+			}
+		}
+
+		public override Object Clone()
+		{
+			StoreContent();
+			return base.Clone();
+		}
+
+		public override void OnSend()
+		{
+			base.OnSend();
+			StoreContent();
+		}
+
+		public override void ClearBody()
+		{
+			base.ClearBody();
+			this.byteBuffer = null;
+			this.dataIn = null;
+			this.dataOut = null;
+			this.bytesRemaining = -1;
+		}
+
+		public void Reset()
+		{
+			StoreContent();
+			this.dataIn = null;
+			this.dataOut = null;
+			this.byteBuffer = null;
+			this.bytesRemaining = -1;
+			this.ReadOnlyBody = true;
+		}
+
+		private void InitializeReading()
+		{
+			FailIfWriteOnlyBody();
+			if(this.dataIn == null)
+			{
+				// TODO - Add support for Message Compression.
+				this.byteBuffer = new MemoryStream(this.Content, false);
+				dataIn = new EndianBinaryReader(byteBuffer);
+			}
+		}
+
+		private void InitializeWriting()
+		{
+			FailIfReadOnlyBody();
+			if(this.dataOut == null)
+			{
+				// TODO - Add support for Message Compression.
+				this.byteBuffer = new MemoryStream();
+				this.dataOut = new EndianBinaryWriter(byteBuffer);
+			}
+		}
+
+		private void StoreContent()
+		{
+			if( dataOut != null)
+			{
+				dataOut.Close();
+				// TODO - Add support for Message Compression.
+
+				this.Content = byteBuffer.ToArray();
+				this.dataOut = null;
+				this.byteBuffer = null;
+			}
+		}
+
+	}
 }
 

Modified: activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/MessageProducer.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/MessageProducer.cs?rev=822538&r1=822537&r2=822538&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/MessageProducer.cs (original)
+++ activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/MessageProducer.cs Tue Oct  6 23:53:12 2009
@@ -271,7 +271,12 @@
             return session.CreateBytesMessage(body);
         }
 
-        public void OnProducerAck(ProducerAck ack)
+		public IStreamMessage CreateStreamMessage()
+		{
+			return session.CreateStreamMessage();
+		}
+
+		public void OnProducerAck(ProducerAck ack)
         {
             Tracer.Debug("Received ProducerAck for Message of Size = {" + ack.Size + "}" );
 

Modified: activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Session.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Session.cs?rev=822538&r1=822537&r2=822538&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Session.cs (original)
+++ activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Session.cs Tue Oct  6 23:53:12 2009
@@ -399,7 +399,12 @@
             return answer;
         }
 
-        public IObjectMessage CreateObjectMessage(object body)
+		public IStreamMessage CreateStreamMessage()
+		{
+			return new ActiveMQStreamMessage();
+		}
+		
+		public IObjectMessage CreateObjectMessage(object body)
         {
             ActiveMQObjectMessage answer = new ActiveMQObjectMessage();
             answer.Body = body;

Modified: activemq/activemq-dotnet/Apache.NMS.EMS/trunk/src/main/csharp/EMSConvert.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.EMS/trunk/src/main/csharp/EMSConvert.cs?rev=822538&r1=822537&r2=822538&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.EMS/trunk/src/main/csharp/EMSConvert.cs (original)
+++ activemq/activemq-dotnet/Apache.NMS.EMS/trunk/src/main/csharp/EMSConvert.cs Tue Oct  6 23:53:12 2009
@@ -124,8 +124,13 @@
 			if(tibcoMessage is TIBCO.EMS.BytesMessage)
 			{
 				return ToNMSBytesMessage(tibcoMessage as TIBCO.EMS.BytesMessage);
-			}
-
+			}
+
+			if(tibcoMessage is TIBCO.EMS.StreamMessage)
+			{
+				return ToNMSStreamMessage(tibcoMessage as TIBCO.EMS.StreamMessage);
+			}
+			
 			if(tibcoMessage is TIBCO.EMS.MapMessage)
 			{
 				return ToNMSMapMessage(tibcoMessage as TIBCO.EMS.MapMessage);
@@ -154,7 +159,14 @@
 			return (null != tibcoBytesMessage
 							? new Apache.NMS.EMS.BytesMessage(tibcoBytesMessage)
 							: null);
-		}
+		}
+
+		public static Apache.NMS.IStreamMessage ToNMSStreamMessage(TIBCO.EMS.StreamMessage tibcoStreamMessage)
+		{
+			return (null != tibcoStreamMessage
+							? new Apache.NMS.EMS.StreamMessage(tibcoStreamMessage)
+							: null);
+		}
 
 		public static Apache.NMS.IMapMessage ToNMSMapMessage(TIBCO.EMS.MapMessage tibcoMapMessage)
 		{
@@ -285,6 +297,6 @@
 			return new EnumerableAdapter(enumerator);
 		}
 
-		#endregion
+		#endregion
 	}
 }

Modified: activemq/activemq-dotnet/Apache.NMS.EMS/trunk/src/main/csharp/MessageProducer.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.EMS/trunk/src/main/csharp/MessageProducer.cs?rev=822538&r1=822537&r2=822538&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.EMS/trunk/src/main/csharp/MessageProducer.cs (original)
+++ activemq/activemq-dotnet/Apache.NMS.EMS/trunk/src/main/csharp/MessageProducer.cs Tue Oct  6 23:53:12 2009
@@ -210,6 +210,14 @@
 			return this.nmsSession.CreateBytesMessage(body);
 		}
 
+		/// <summary>
+		/// Creates a new stream message
+		/// </summary>
+		public Apache.NMS.IStreamMessage CreateStreamMessage()
+		{
+			return this.nmsSession.CreateStreamMessage();
+		}
+
 		#endregion
 
 		#region IDisposable Members

Modified: activemq/activemq-dotnet/Apache.NMS.EMS/trunk/src/main/csharp/Session.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.EMS/trunk/src/main/csharp/Session.cs?rev=822538&r1=822537&r2=822538&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.EMS/trunk/src/main/csharp/Session.cs (original)
+++ activemq/activemq-dotnet/Apache.NMS.EMS/trunk/src/main/csharp/Session.cs Tue Oct  6 23:53:12 2009
@@ -164,6 +164,11 @@
 			return bytesMessage;
 		}
 
+		public Apache.NMS.IStreamMessage CreateStreamMessage()
+		{
+			return EMSConvert.ToNMSStreamMessage(this.tibcoSession.CreateStreamMessage());
+		}
+
 		public Apache.NMS.IObjectMessage CreateObjectMessage(Object body)
 		{
 			return EMSConvert.ToNMSObjectMessage(this.tibcoSession.CreateObjectMessage(body));

Copied: activemq/activemq-dotnet/Apache.NMS.EMS/trunk/src/main/csharp/StreamMessage.cs (from r822525, 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/StreamMessage.cs?p2=activemq/activemq-dotnet/Apache.NMS.EMS/trunk/src/main/csharp/StreamMessage.cs&p1=activemq/activemq-dotnet/Apache.NMS.EMS/trunk/src/main/csharp/BytesMessage.cs&r1=822525&r2=822538&rev=822538&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/StreamMessage.cs Tue Oct  6 23:53:12 2009
@@ -17,163 +17,139 @@
 
 namespace Apache.NMS.EMS
 {
-	class BytesMessage : Apache.NMS.EMS.Message, Apache.NMS.IBytesMessage
+	class StreamMessage : Apache.NMS.EMS.Message, Apache.NMS.IStreamMessage
 	{
-		public TIBCO.EMS.BytesMessage tibcoBytesMessage
+		public TIBCO.EMS.StreamMessage tibcoStreamMessage
 		{
-			get { return this.tibcoMessage as TIBCO.EMS.BytesMessage; }
+			get { return this.tibcoMessage as TIBCO.EMS.StreamMessage; }
 			set { this.tibcoMessage = value; }
 		}
 
-		public BytesMessage(TIBCO.EMS.BytesMessage message)
+		public StreamMessage(TIBCO.EMS.StreamMessage message)
 			: base(message)
 		{
 		}
 
-		#region IBytesMessage Members
-
-		public byte[] Content
-		{
-			get
-			{
-				int contentLength = (int) this.tibcoBytesMessage.BodyLength;
-				byte[] msgContent = new byte[contentLength];
-
-				this.tibcoBytesMessage.Reset();
-				this.tibcoBytesMessage.ReadBytes(msgContent, contentLength);
-				return msgContent;
-			}
-
-			set
-			{
-				this.tibcoBytesMessage.ClearBody();
-				this.tibcoBytesMessage.WriteBytes(value, 0, value.Length);
-			}
-		}
-
-		public long BodyLength
-		{
-			get { return this.tibcoBytesMessage.BodyLength; }
-		}
+		#region IStreamMessage Members
 
 		public bool ReadBoolean()
 		{
-			return this.tibcoBytesMessage.ReadBoolean();
+			return this.tibcoStreamMessage.ReadBoolean();
 		}
 
 		public byte ReadByte()
 		{
-			return (byte) this.tibcoBytesMessage.ReadByte();
-		}
-
-		public int ReadBytes(byte[] value, int length)
-		{
-			return this.tibcoBytesMessage.ReadBytes(value, length);
+			return this.tibcoStreamMessage.ReadByte();
 		}
 
 		public int ReadBytes(byte[] value)
 		{
-			return this.tibcoBytesMessage.ReadBytes(value);
+			return this.tibcoStreamMessage.ReadBytes(value);
 		}
 
 		public char ReadChar()
 		{
-			return this.tibcoBytesMessage.ReadChar();
+			return this.tibcoStreamMessage.ReadChar();
 		}
 
 		public double ReadDouble()
 		{
-			return this.tibcoBytesMessage.ReadDouble();
+			return this.tibcoStreamMessage.ReadDouble();
 		}
 
 		public short ReadInt16()
 		{
-			return this.tibcoBytesMessage.ReadShort();
+			return this.tibcoStreamMessage.ReadShort();
 		}
 
 		public int ReadInt32()
 		{
-			return this.tibcoBytesMessage.ReadInt();
+			return this.tibcoStreamMessage.ReadInt();
 		}
 
 		public long ReadInt64()
 		{
-			return this.tibcoBytesMessage.ReadLong();
+			return this.tibcoStreamMessage.ReadLong();
+		}
+
+		public object ReadObject()
+		{
+			return this.tibcoStreamMessage.ReadObject();
 		}
 
 		public float ReadSingle()
 		{
-			return this.tibcoBytesMessage.ReadFloat();
+			return this.tibcoStreamMessage.ReadFloat();
 		}
 
 		public string ReadString()
 		{
-			return this.tibcoBytesMessage.ReadUTF();
+			return this.tibcoStreamMessage.ReadString();
 		}
 
 		public void Reset()
 		{
-			this.tibcoBytesMessage.Reset();
+			this.tibcoStreamMessage.Reset();
 		}
 
 		public void WriteBoolean(bool value)
 		{
-			this.tibcoBytesMessage.WriteBoolean(value);
+			this.tibcoStreamMessage.WriteBoolean(value);
 		}
 
 		public void WriteByte(byte value)
 		{
-			this.tibcoBytesMessage.WriteByte(value);
+			this.tibcoStreamMessage.WriteByte(value);
 		}
 
 		public void WriteBytes(byte[] value, int offset, int length)
 		{
-			this.tibcoBytesMessage.WriteBytes(value, offset, length);
+			this.tibcoStreamMessage.WriteBytes(value, offset, length);
 		}
 
 		public void WriteBytes(byte[] value)
 		{
-			this.tibcoBytesMessage.WriteBytes(value);
+			this.tibcoStreamMessage.WriteBytes(value);
 		}
 
 		public void WriteChar(char value)
 		{
-			this.tibcoBytesMessage.WriteChar(value);
+			this.tibcoStreamMessage.WriteChar(value);
 		}
 
 		public void WriteDouble(double value)
 		{
-			this.tibcoBytesMessage.WriteDouble(value);
+			this.tibcoStreamMessage.WriteDouble(value);
 		}
 
 		public void WriteInt16(short value)
 		{
-			this.tibcoBytesMessage.WriteShort(value);
+			this.tibcoStreamMessage.WriteShort(value);
 		}
 
 		public void WriteInt32(int value)
 		{
-			this.tibcoBytesMessage.WriteInt(value);
+			this.tibcoStreamMessage.WriteInt(value);
 		}
 
 		public void WriteInt64(long value)
 		{
-			this.tibcoBytesMessage.WriteLong(value);
+			this.tibcoStreamMessage.WriteLong(value);
 		}
 
 		public void WriteObject(object value)
 		{
-			this.tibcoBytesMessage.WriteObject(value);
+			this.tibcoStreamMessage.WriteObject(value);
 		}
 
 		public void WriteSingle(float value)
 		{
-			this.tibcoBytesMessage.WriteFloat(value);
+			this.tibcoStreamMessage.WriteFloat(value);
 		}
 
 		public void WriteString(string value)
 		{
-			this.tibcoBytesMessage.WriteUTF(value);
+			this.tibcoStreamMessage.WriteString(value);
 		}
 
 		#endregion

Modified: activemq/activemq-dotnet/Apache.NMS.EMS/trunk/vs2008-ems.csproj
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.EMS/trunk/vs2008-ems.csproj?rev=822538&r1=822537&r2=822538&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.EMS/trunk/vs2008-ems.csproj (original)
+++ activemq/activemq-dotnet/Apache.NMS.EMS/trunk/vs2008-ems.csproj Tue Oct  6 23:53:12 2009
@@ -71,6 +71,7 @@
     <Compile Include="src\main\csharp\CommonAssemblyInfo.cs" />
     <Compile Include="src\main\csharp\Connection.cs" />
     <Compile Include="src\main\csharp\ConnectionFactory.cs" />
+    <Compile Include="src\main\csharp\StreamMessage.cs" />
     <Compile Include="src\main\csharp\QueueBrowser.cs" />
     <Compile Include="src\main\csharp\Destination.cs" />
     <Compile Include="src\main\csharp\Dispatcher.cs" />

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=822538&r1=822537&r2=822538&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 Tue Oct  6 23:53:12 2009
@@ -32,6 +32,7 @@
 		private MsgDeliveryMode deliveryMode;
 		private MsgPriority priority;
 		private Destination replyTo;
+		private byte[] content;
 		private string type;
 		private event AcknowledgeHandler Acknowledger;
 		private DateTime timestamp = new DateTime();
@@ -62,6 +63,7 @@
 		/// </summary>
 		public virtual void ClearBody()
 		{
+			this.Content = null;
 			this.readOnlyMsgBody = false;
 		}
 
@@ -167,6 +169,12 @@
 			set { timestamp = value; }
 		}
 
+		public byte[] Content
+		{
+			get { return content; }
+			set { this.content = value; }
+		}
+
 		/// <summary>
 		/// The type name of this message
 		/// </summary>



Mime
View raw message