http://git-wip-us.apache.org/repos/asf/activemq-nms-msmq/blob/e964b541/tags/1.2.0-RC1/src/main/csharp/StreamMessage.cs ---------------------------------------------------------------------- diff --git a/tags/1.2.0-RC1/src/main/csharp/StreamMessage.cs b/tags/1.2.0-RC1/src/main/csharp/StreamMessage.cs new file mode 100644 index 0000000..c939867 --- /dev/null +++ b/tags/1.2.0-RC1/src/main/csharp/StreamMessage.cs @@ -0,0 +1,893 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +using System; +using System.IO; +using Apache.NMS.Util; + +namespace Apache.NMS.MSMQ +{ + public class StreamMessage : BaseMessage, IStreamMessage + { + private EndianBinaryReader dataIn = null; + private EndianBinaryWriter dataOut = null; + private MemoryStream byteBuffer = null; + private int bytesRemaining = -1; + + 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 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; + } + } + } +}
http://git-wip-us.apache.org/repos/asf/activemq-nms-msmq/blob/e964b541/tags/1.2.0-RC1/src/main/csharp/TextMessage.cs ---------------------------------------------------------------------- diff --git a/tags/1.2.0-RC1/src/main/csharp/TextMessage.cs b/tags/1.2.0-RC1/src/main/csharp/TextMessage.cs new file mode 100644 index 0000000..9a8c61e --- /dev/null +++ b/tags/1.2.0-RC1/src/main/csharp/TextMessage.cs @@ -0,0 +1,101 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +using System; + + +namespace Apache.NMS.MSMQ +{ + public class TextMessage : BaseMessage, ITextMessage + { + public const int SIZE_OF_INT = 4; // sizeof(int) - though causes unsafe issues with net 1.1 + + private String text; + + public TextMessage() + { + } + + public TextMessage(String text) + { + this.Text = text; + } + + + // Properties + + public string Text + { + get + { + if(text == null) + { + // now lets read the content + byte[] data = this.Content; + if(data != null) + { + // TODO assume that the text is ASCII + char[] chars = new char[data.Length - SIZE_OF_INT]; + for(int i = 0; i < chars.Length; i++) + { + chars[i] = (char) data[i + SIZE_OF_INT]; + } + text = new String(chars); + } + } + return text; + } + + set + { + this.text = value; + byte[] data = null; + if(text != null) + { + // TODO assume that the text is ASCII + + byte[] sizePrefix = System.BitConverter.GetBytes(text.Length); + data = new byte[text.Length + sizePrefix.Length]; //int at the front of it + + // add the size prefix + for(int j = 0; j < sizePrefix.Length; j++) + { + // The bytes need to be encoded in big endian + if(BitConverter.IsLittleEndian) + { + data[j] = sizePrefix[sizePrefix.Length - j - 1]; + } + else + { + data[j] = sizePrefix[j]; + } + } + + // Add the data. + char[] chars = text.ToCharArray(); + for(int i = 0; i < chars.Length; i++) + { + data[i + sizePrefix.Length] = (byte) chars[i]; + } + } + this.Content = data; + + } + } + + } +} + http://git-wip-us.apache.org/repos/asf/activemq-nms-msmq/blob/e964b541/tags/1.2.0-RC1/src/main/ndoc/NamespaceSummary.xml ---------------------------------------------------------------------- diff --git a/tags/1.2.0-RC1/src/main/ndoc/NamespaceSummary.xml b/tags/1.2.0-RC1/src/main/ndoc/NamespaceSummary.xml new file mode 100644 index 0000000..b8e19d5 --- /dev/null +++ b/tags/1.2.0-RC1/src/main/ndoc/NamespaceSummary.xml @@ -0,0 +1,21 @@ +<!-- + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> +<namespaces> + <namespace name="NMS"> + The <b>NMS</b> namespace defines the .Net Message System API which is an interface to messaging systems rather like JMS is for Java. + </namespace> +</namespaces> http://git-wip-us.apache.org/repos/asf/activemq-nms-msmq/blob/e964b541/tags/1.2.0-RC1/src/main/sandcastle/feedback_content.xml ---------------------------------------------------------------------- diff --git a/tags/1.2.0-RC1/src/main/sandcastle/feedback_content.xml b/tags/1.2.0-RC1/src/main/sandcastle/feedback_content.xml new file mode 100644 index 0000000..ee30a12 --- /dev/null +++ b/tags/1.2.0-RC1/src/main/sandcastle/feedback_content.xml @@ -0,0 +1,32 @@ +<content xml:space="preserve"> + + <item id="fb_alias">[email protected]</item> + <item id="fb_product"></item> + <item id="fb_deliverable"></item> + + <item id="fb_subject">Customer%20Feedback</item> + <item id="fb_body">%0\dThank%20you%20for%20your%20feedback.%20The%20developer%20writing%20teams%20use%20your%20feedback%20to%20improve%20documentation.%20While%20we%20are%20reviewing%20your%20feedback,%20we%20may%20send%20you%20e-mail%20to%20ask%20for%20clarification%20or%20feedback%20on%20a%20solution.%20We%20do%20not%20use%20your%20e-mail%20address%20for%20any%20other%20purpose.%0\d</item> + + <item id="fb_headerFeedBack">Send Feedback</item> + + + <!-- feedback values for sandcastle scenario --> + + <item id="feedback_alias"></item> + <item id="feedback_product"></item> + <item id="feedback_deliverable"></item> + <item id="feedback_fileVersion"></item> + <item id="feedback_topicVersion"></item> + <item id="feedback_body"></item> + <item id="feedback_subject"></item> + + <item id="fb_Introduction">We value your feedback. To rate this topic and send feedback about this topic to the documentation team, click a rating, and then click <b>Send Feedback</b>. For assistance with support issues, refer to the technical support information included with the product.</item> + + <item id="fb_Send">Send Feedback</item> + <item id="fb_Poor">Poor</item> + <item id="fb_Excellent">Outstanding</item> + <item id="fb_EnterFeedbackText">To e-mail your feedback, click here:</item> + <item id="fb_Title">Documentation Feedback</item> + <item id="fb_altIcon">Display feedback instructions at the bottom of the page.</item> + +</content> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/activemq-nms-msmq/blob/e964b541/tags/1.2.0-RC1/src/test/csharp/MSMQTest.cs ---------------------------------------------------------------------- diff --git a/tags/1.2.0-RC1/src/test/csharp/MSMQTest.cs b/tags/1.2.0-RC1/src/test/csharp/MSMQTest.cs new file mode 100644 index 0000000..5cf5c09 --- /dev/null +++ b/tags/1.2.0-RC1/src/test/csharp/MSMQTest.cs @@ -0,0 +1,120 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +using System; +using System.Messaging; +using NUnit.Framework; + +namespace Apache.NMS.MSMQ +{ + /// <summary> + /// Use to test and verify MSMQ behaviour. + /// </summary> + [TestFixture] + public class MSMQTest + { + String queueName = ".\\Private$\\FOO"; + + [SetUp] + public void SetUp() + { + } + + [TearDown] + public void TearDown() + { + } + + [Test] + public void TestSendAndReceive() + { + // check to make sure the message queue does not exist already + if(!MessageQueue.Exists(queueName)) + { + // create the new message queue and make it transactional + MessageQueue MQ = MessageQueue.Create(queueName, true); + + // set the label name and close the message queue + MQ.Label = "FOO"; + MQ.Close(); + + Console.WriteLine("Created Queue: " + queueName); + //Assert.Fail("Should have thrown an exception!"); + } + else + { + Console.WriteLine("Queue Existed: " + queueName); + } + + if(!MessageQueue.Exists(".\\Private$\\BAR")) + { + // create the new message queue and make it transactional + MessageQueue MQ = MessageQueue.Create(".\\Private$\\BAR", true); + + // set the label name and close the message queue + MQ.Label = "BAR Label"; + MQ.Close(); + } + else + { + Console.WriteLine("Queue Existed: " + queueName); + } + + // create a message queue transaction and start it + MessageQueueTransaction Transaction = new MessageQueueTransaction(); + Transaction.Begin(); + + MessageQueue MQueue = new MessageQueue(queueName); + + Message Msg = new Message("Hello World"); + Msg.ResponseQueue = new MessageQueue(".\\Private$\\BAR"); + Msg.Priority = MessagePriority.Normal; + Msg.UseJournalQueue = true; + Msg.Label = "Test Label"; + + Msg.AcknowledgeType = AcknowledgeTypes.FullReceive; + Msg.AdministrationQueue = Msg.ResponseQueue; + + // send the message + MQueue.Send(Msg, Transaction); + MQueue.Send(Msg, Transaction); + MQueue.Send(Msg, Transaction); + + // commit the transaction + Transaction.Commit(); + + // Read the message. + MQueue.MessageReadPropertyFilter.SetAll(); + + // the target type we have stored in the message body + + ((XmlMessageFormatter) MQueue.Formatter).TargetTypes = new Type[] { typeof(String) }; + + // read the message from the queue, but only wait for 5 sec + Msg = MQueue.Receive(new TimeSpan(0, 0, 5)); + + // read the order from the message body + Console.WriteLine("Received: " + Msg.Body); + + // close the mesage queue + MQueue.Close(); + } + } +} + + + http://git-wip-us.apache.org/repos/asf/activemq-nms-msmq/blob/e964b541/tags/1.2.0-RC1/vs2008-msmq-test.csproj ---------------------------------------------------------------------- diff --git a/tags/1.2.0-RC1/vs2008-msmq-test.csproj b/tags/1.2.0-RC1/vs2008-msmq-test.csproj new file mode 100644 index 0000000..ea54c4b --- /dev/null +++ b/tags/1.2.0-RC1/vs2008-msmq-test.csproj @@ -0,0 +1,121 @@ +<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5"> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <ProductVersion>9.0.30729</ProductVersion> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{2F31ED5C-44A2-464A-BD55-2B5B010654E8}</ProjectGuid> + <OutputType>Library</OutputType> + <RootNamespace>Apache.NMS.MSMQ.Test</RootNamespace> + <AssemblyName>Apache.NMS.MSMQ.Test</AssemblyName> + <WarningLevel>4</WarningLevel> + <StartupObject> + </StartupObject> + <FileUpgradeFlags> + </FileUpgradeFlags> + <OldToolsVersion>2.0</OldToolsVersion> + <UpgradeBackupLocation> + </UpgradeBackupLocation> + <PublishUrl>publish\</PublishUrl> + <Install>true</Install> + <InstallFrom>Disk</InstallFrom> + <UpdateEnabled>false</UpdateEnabled> + <UpdateMode>Foreground</UpdateMode> + <UpdateInterval>7</UpdateInterval> + <UpdateIntervalUnits>Days</UpdateIntervalUnits> + <UpdatePeriodically>false</UpdatePeriodically> + <UpdateRequired>false</UpdateRequired> + <MapFileExtensions>true</MapFileExtensions> + <ApplicationRevision>0</ApplicationRevision> + <ApplicationVersion>1.0.0.%2a</ApplicationVersion> + <IsWebBootstrapper>false</IsWebBootstrapper> + <UseApplicationTrust>false</UseApplicationTrust> + <BootstrapperEnabled>true</BootstrapperEnabled> + <SignAssembly>true</SignAssembly> + <AssemblyOriginatorKeyFile>keyfile\NMSKey.snk</AssemblyOriginatorKeyFile> + <SccProjectName>Svn</SccProjectName> + <SccLocalPath>Svn</SccLocalPath> + <SccAuxPath>Svn</SccAuxPath> + <SccProvider>SubversionScc</SccProvider> + <RunPostBuildEvent>OnOutputUpdated</RunPostBuildEvent> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + <DebugSymbols>true</DebugSymbols> + <DebugType>full</DebugType> + <Optimize>false</Optimize> + <OutputPath>build\net-2.0\debug\</OutputPath> + <DefineConstants>TRACE;DEBUG;NET,NET_2_0</DefineConstants> + <AllowUnsafeBlocks>false</AllowUnsafeBlocks> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + <DebugSymbols>true</DebugSymbols> + <Optimize>true</Optimize> + <OutputPath>build\net-2.0\release\</OutputPath> + <DefineConstants>TRACE;NET,NET_2_0</DefineConstants> + <AllowUnsafeBlocks>false</AllowUnsafeBlocks> + <DebugType>full</DebugType> + </PropertyGroup> + <ItemGroup> + <Reference Include="Apache.NMS, Version=1.1.0.0, Culture=neutral, processorArchitecture=MSIL"> + <SpecificVersion>False</SpecificVersion> + <HintPath>lib\Apache.NMS\net-2.0\Apache.NMS.dll</HintPath> + </Reference> + <Reference Include="Apache.NMS.Test, Version=1.1.0.0, Culture=neutral, processorArchitecture=MSIL"> + <SpecificVersion>False</SpecificVersion> + <HintPath>lib\Apache.NMS\net-2.0\Apache.NMS.Test.dll</HintPath> + </Reference> + <Reference Include="nunit.framework, Version=2.4.8.0, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL"> + <SpecificVersion>False</SpecificVersion> + <HintPath>lib\NUnit\net-2.0\nunit.framework.dll</HintPath> + </Reference> + <Reference Include="nunit.framework.extensions, Version=2.4.8.0, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL"> + <SpecificVersion>False</SpecificVersion> + <HintPath>lib\NUnit\net-2.0\nunit.framework.extensions.dll</HintPath> + </Reference> + <Reference Include="System" /> + <Reference Include="System.Messaging" /> + <Reference Include="System.Xml" /> + </ItemGroup> + <ItemGroup> + <Compile Include="src\test\csharp\CommonAssemblyInfo.cs" /> + <Compile Include="src\test\csharp\MSMQTest.cs"> + <SubType>Code</SubType> + </Compile> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="vs2008-msmq.csproj"> + <Project>{A5FCA129-991B-4CB2-987A-B25E43B0F5EC}</Project> + <Name>vs2008-msmq</Name> + </ProjectReference> + </ItemGroup> + <ItemGroup> + <BootstrapperPackage Include="Microsoft.Net.Framework.2.0"> + <Visible>False</Visible> + <ProductName>.NET Framework 2.0 %28x86%29</ProductName> + <Install>true</Install> + </BootstrapperPackage> + <BootstrapperPackage Include="Microsoft.Net.Framework.3.0"> + <Visible>False</Visible> + <ProductName>.NET Framework 3.0 %28x86%29</ProductName> + <Install>false</Install> + </BootstrapperPackage> + <BootstrapperPackage Include="Microsoft.Net.Framework.3.5"> + <Visible>False</Visible> + <ProductName>.NET Framework 3.5</ProductName> + <Install>false</Install> + </BootstrapperPackage> + </ItemGroup> + <ItemGroup> + <Content Include="nmsprovider-test.config"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </Content> + </ItemGroup> + <ItemGroup> + <None Include="keyfile\NMSKey.snk" /> + </ItemGroup> + <Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" /> + <PropertyGroup> + <PostBuildEvent>cd $(ProjectDir) +nant -nologo -q install-all -D:compile.skip=true</PostBuildEvent> + </PropertyGroup> +</Project> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/activemq-nms-msmq/blob/e964b541/tags/1.2.0-RC1/vs2008-msmq.csproj ---------------------------------------------------------------------- diff --git a/tags/1.2.0-RC1/vs2008-msmq.csproj b/tags/1.2.0-RC1/vs2008-msmq.csproj new file mode 100644 index 0000000..6221c67 --- /dev/null +++ b/tags/1.2.0-RC1/vs2008-msmq.csproj @@ -0,0 +1,114 @@ +<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5"> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <ProductVersion>9.0.30729</ProductVersion> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{A5FCA129-991B-4CB2-987A-B25E43B0F5EC}</ProjectGuid> + <OutputType>Library</OutputType> + <RootNamespace>Apache.NMS.MSMQ</RootNamespace> + <AssemblyName>Apache.NMS.MSMQ</AssemblyName> + <WarningLevel>4</WarningLevel> + <StartupObject> + </StartupObject> + <SignAssembly>true</SignAssembly> + <AssemblyOriginatorKeyFile>keyfile\NMSKey.snk</AssemblyOriginatorKeyFile> + <FileUpgradeFlags> + </FileUpgradeFlags> + <OldToolsVersion>2.0</OldToolsVersion> + <UpgradeBackupLocation> + </UpgradeBackupLocation> + <PublishUrl>publish\</PublishUrl> + <Install>true</Install> + <InstallFrom>Disk</InstallFrom> + <UpdateEnabled>false</UpdateEnabled> + <UpdateMode>Foreground</UpdateMode> + <UpdateInterval>7</UpdateInterval> + <UpdateIntervalUnits>Days</UpdateIntervalUnits> + <UpdatePeriodically>false</UpdatePeriodically> + <UpdateRequired>false</UpdateRequired> + <MapFileExtensions>true</MapFileExtensions> + <ApplicationRevision>0</ApplicationRevision> + <ApplicationVersion>1.0.0.%2a</ApplicationVersion> + <IsWebBootstrapper>false</IsWebBootstrapper> + <UseApplicationTrust>false</UseApplicationTrust> + <BootstrapperEnabled>true</BootstrapperEnabled> + <SccProjectName>Svn</SccProjectName> + <SccLocalPath>Svn</SccLocalPath> + <SccAuxPath>Svn</SccAuxPath> + <SccProvider>SubversionScc</SccProvider> + <RunPostBuildEvent>OnOutputUpdated</RunPostBuildEvent> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + <DebugSymbols>true</DebugSymbols> + <DebugType>full</DebugType> + <Optimize>false</Optimize> + <OutputPath>build\net-2.0\debug\</OutputPath> + <DefineConstants>TRACE;DEBUG;NET,NET_2_0</DefineConstants> + <AllowUnsafeBlocks>false</AllowUnsafeBlocks> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + <DebugSymbols>true</DebugSymbols> + <Optimize>true</Optimize> + <OutputPath>build\net-2.0\release\</OutputPath> + <DefineConstants>TRACE;NET,NET_2_0</DefineConstants> + <AllowUnsafeBlocks>false</AllowUnsafeBlocks> + <DebugType>full</DebugType> + </PropertyGroup> + <ItemGroup> + <Reference Include="Apache.NMS, Version=1.1.0.0, Culture=neutral, processorArchitecture=MSIL"> + <SpecificVersion>False</SpecificVersion> + <HintPath>lib\Apache.NMS\net-2.0\Apache.NMS.dll</HintPath> + </Reference> + <Reference Include="System" /> + <Reference Include="System.Data" /> + <Reference Include="System.Messaging" /> + <Reference Include="System.Xml" /> + </ItemGroup> + <ItemGroup> + <Compile Include="src\main\csharp\BaseMessage.cs" /> + <Compile Include="src\main\csharp\BytesMessage.cs" /> + <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\ConnectionMetaData.cs" /> + <Compile Include="src\main\csharp\DefaultMessageConverter.cs" /> + <Compile Include="src\main\csharp\Destination.cs" /> + <Compile Include="src\main\csharp\IMessageConverter.cs" /> + <Compile Include="src\main\csharp\MapMessage.cs" /> + <Compile Include="src\main\csharp\MessageConsumer.cs" /> + <Compile Include="src\main\csharp\MessageProducer.cs" /> + <Compile Include="src\main\csharp\ObjectMessage.cs" /> + <Compile Include="src\main\csharp\Queue.cs" /> + <Compile Include="src\main\csharp\Session.cs" /> + <Compile Include="src\main\csharp\StreamMessage.cs" /> + <Compile Include="src\main\csharp\TextMessage.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="keyfile\NMSKey.snk" /> + </ItemGroup> + <ItemGroup> + <BootstrapperPackage Include="Microsoft.Net.Framework.2.0"> + <Visible>False</Visible> + <ProductName>.NET Framework 2.0 %28x86%29</ProductName> + <Install>true</Install> + </BootstrapperPackage> + <BootstrapperPackage Include="Microsoft.Net.Framework.3.0"> + <Visible>False</Visible> + <ProductName>.NET Framework 3.0 %28x86%29</ProductName> + <Install>false</Install> + </BootstrapperPackage> + <BootstrapperPackage Include="Microsoft.Net.Framework.3.5"> + <Visible>False</Visible> + <ProductName>.NET Framework 3.5</ProductName> + <Install>false</Install> + </BootstrapperPackage> + </ItemGroup> + <Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" /> + <PropertyGroup> + <PreBuildEvent>cd $(ProjectDir) +nant -nologo download-vendor -D:vendor.build.config=$(ConfigurationName) -D:vendor.build.framework=net-2.0</PreBuildEvent> + <PostBuildEvent>cd $(ProjectDir) +nant -nologo -q install-all -D:compile.skip=true</PostBuildEvent> + </PropertyGroup> +</Project> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/activemq-nms-msmq/blob/e964b541/tags/1.2.0-RC1/vs2008-msmq.sln ---------------------------------------------------------------------- diff --git a/tags/1.2.0-RC1/vs2008-msmq.sln b/tags/1.2.0-RC1/vs2008-msmq.sln new file mode 100644 index 0000000..a51006f --- /dev/null +++ b/tags/1.2.0-RC1/vs2008-msmq.sln @@ -0,0 +1,30 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "vs2008-msmq", "vs2008-msmq.csproj", "{A5FCA129-991B-4CB2-987A-B25E43B0F5EC}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "vs2008-msmq-test", "vs2008-msmq-test.csproj", "{2F31ED5C-44A2-464A-BD55-2B5B010654E8}" +EndProject +Global + GlobalSection(SubversionScc) = preSolution + Svn-Managed = True + Manager = AnkhSVN - Subversion Support for Visual Studio + EndGlobalSection + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {A5FCA129-991B-4CB2-987A-B25E43B0F5EC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A5FCA129-991B-4CB2-987A-B25E43B0F5EC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A5FCA129-991B-4CB2-987A-B25E43B0F5EC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A5FCA129-991B-4CB2-987A-B25E43B0F5EC}.Release|Any CPU.Build.0 = Release|Any CPU + {2F31ED5C-44A2-464A-BD55-2B5B010654E8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2F31ED5C-44A2-464A-BD55-2B5B010654E8}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2F31ED5C-44A2-464A-BD55-2B5B010654E8}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2F31ED5C-44A2-464A-BD55-2B5B010654E8}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal
