Apache.NMS.ActiveMQ.Commands.ActiveMQStreamMessage.WriteString C# (CSharp) Method

WriteString() public method

public WriteString ( string value ) : void
value string
return void
        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);
            }
        }

Usage Example

        public void TestReadBigString()
        {
            ActiveMQStreamMessage msg = new ActiveMQStreamMessage();
            // Test with a 1Meg String
            StringBuilder bigSB = new StringBuilder(1024 * 1024);
            for(int i = 0; i < 1024 * 1024; i++)
            {
                bigSB.Append((char)'a' + i % 26);
            }
            String bigString = bigSB.ToString();

            msg.WriteString(bigString);
            msg.Reset();
            Assert.AreEqual(bigString, msg.ReadString());
        }
All Usage Examples Of Apache.NMS.ActiveMQ.Commands.ActiveMQStreamMessage::WriteString