├── keyfile └── NMSKey.snk ├── Apache.NMS.MSMQ.Test.nunit ├── NOTICE.txt ├── src ├── main │ ├── ndoc │ │ └── NamespaceSummary.xml │ ├── csharp │ │ ├── MapMessage.cs │ │ ├── Selector │ │ │ ├── IExpression.cs │ │ │ ├── BooleanConstantExpression.cs │ │ │ ├── IBooleanExpression.cs │ │ │ ├── BooleanUnaryExpression.cs │ │ │ ├── LesserExpression.cs │ │ │ ├── GreaterExpression.cs │ │ │ ├── LesserOrEqualExpression.cs │ │ │ ├── GreaterOrEqualExpression.cs │ │ │ ├── NOTExpression.cs │ │ │ ├── BooleanCastExpression.cs │ │ │ ├── PropertyExpression.cs │ │ │ ├── EqualExpression.cs │ │ │ ├── ORExpression.cs │ │ │ ├── ANDExpression.cs │ │ │ ├── LogicExpression.cs │ │ │ ├── SelectorParserConstants.cs │ │ │ ├── NegateExpression.cs │ │ │ ├── IsNullExpression.cs │ │ │ ├── BinaryExpression.cs │ │ │ ├── ArithmeticExpression.cs │ │ │ ├── UnaryExpression.cs │ │ │ ├── Token.cs │ │ │ ├── MessageEvaluationContext.cs │ │ │ ├── ModExpression.cs │ │ │ ├── DivideExpression.cs │ │ │ ├── MinusExpression.cs │ │ │ ├── MultiplyExpression.cs │ │ │ ├── PlusExpression.cs │ │ │ ├── InExpression.cs │ │ │ ├── LikeExpression.cs │ │ │ └── TokenMgrError.cs │ │ ├── IMessageConverter.cs │ │ ├── IMessageConverterEx.cs │ │ ├── ObjectMessage.cs │ │ ├── TextMessage.cs │ │ ├── ConnectionMetaData.cs │ │ ├── Destination.cs │ │ ├── Readers │ │ │ ├── MessageReaderUtil.cs │ │ │ └── IMessageReader.cs │ │ ├── QueueBrowser.cs │ │ └── ConnectionFactory.cs │ └── sandcastle │ │ └── feedback_content.xml └── test │ └── csharp │ ├── Commands │ ├── ObjectMessage.cs │ ├── TextMessage.cs │ ├── Topic.cs │ ├── Queue.cs │ ├── TempDestination.cs │ ├── TempTopic.cs │ ├── TempQueue.cs │ └── MapMessage.cs │ ├── MSMQMessageTest.cs │ ├── MSMQNMSPropertyTest.cs │ ├── MSMQTextMessageTest.cs │ ├── MSMQStreamMessageTest.cs │ ├── MSMQRequestResponseTest.cs │ ├── MSMQBadConsumeTest.cs │ ├── MSMQXmlMessageTest.cs │ ├── MSMQMessageTransformerTest.cs │ ├── MSMQTestSupport.cs │ ├── MSMQBytesMessageTest.cs │ ├── MSMQMapMessageTest.cs │ ├── MSMQTempDestinationDeletionTest.cs │ ├── BadConsumeTest.cs │ ├── MSMQTempDestinationTest.cs │ ├── NMSTracer.cs │ ├── MSMQDurableTest.cs │ ├── RequestResponseTest.cs │ ├── MSMQProducerTest.cs │ ├── TempDestinationDeletionTest.cs │ ├── TextMessageTest.cs │ ├── MSMQForeignMessageTransformationTest.cs │ ├── NMSPropertyTest.cs │ ├── MSMQConnectionTest.cs │ ├── MSMQTest.cs │ ├── MSMQAsyncConsumeTest.cs │ ├── EndianTest.cs │ ├── MSMQTransactionTest.cs │ ├── StreamMessageTest.cs │ ├── ProducerTest.cs │ └── MessageTransformerTest.cs ├── nmsprovider-test.config ├── vs2008-msmq.sln ├── msmqprovider-test.config ├── README.txt └── package.ps1 /keyfile/NMSKey.snk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apache/activemq-nms-msmq/main/keyfile/NMSKey.snk -------------------------------------------------------------------------------- /Apache.NMS.MSMQ.Test.nunit: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /NOTICE.txt: -------------------------------------------------------------------------------- 1 | ========================================================================= 2 | == NOTICE file corresponding to the section 4 d of == 3 | == the Apache License, Version 2.0, == 4 | == in this case for the Apache ActiveMQ distribution. == 5 | ========================================================================= 6 | 7 | Apache ActiveMQ 8 | Copyright 2005-2017 The Apache Software Foundation 9 | 10 | This product includes software developed by 11 | The Apache Software Foundation (http://www.apache.org/). 12 | 13 | -------------------------------------------------------------------------------- /src/main/ndoc/NamespaceSummary.xml: -------------------------------------------------------------------------------- 1 | 17 | 18 | 19 | The NMS namespace defines the .Net Message System API which is an interface to messaging systems rather like JMS is for Java. 20 | 21 | 22 | -------------------------------------------------------------------------------- /nmsprovider-test.config: -------------------------------------------------------------------------------- 1 | 2 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /src/main/csharp/MapMessage.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | using Apache.NMS.Util; 19 | 20 | namespace Apache.NMS.MSMQ 21 | { 22 | public class MapMessage : BaseMessage, IMapMessage 23 | { 24 | private IPrimitiveMap body = new PrimitiveMap(); 25 | 26 | public IPrimitiveMap Body 27 | { 28 | get { return body; } 29 | set { body = value; } 30 | } 31 | } 32 | } 33 | 34 | -------------------------------------------------------------------------------- /src/main/csharp/Selector/IExpression.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | using System; 18 | 19 | namespace Apache.NMS.Selector 20 | { 21 | /// 22 | /// Represents an expression 23 | /// 24 | public interface IExpression 25 | { 26 | /// 27 | /// Evaluates the expression. 28 | /// 29 | /// Evaluation context. 30 | /// The result of the evaluation. 31 | object Evaluate(MessageEvaluationContext message); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/test/csharp/Commands/ObjectMessage.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | using System; 19 | using System.Collections; 20 | using System.IO; 21 | 22 | using Apache.NMS; 23 | 24 | namespace Apache.NMS.Commands 25 | { 26 | public class ObjectMessage : Message, IObjectMessage 27 | { 28 | private object body; 29 | 30 | public override string ToString() { 31 | return GetType().Name + "[" 32 | + " ]"; 33 | } 34 | 35 | // Properties 36 | 37 | public object Body 38 | { 39 | get { return body; } 40 | set { body = value; } 41 | } 42 | 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main/csharp/Selector/BooleanConstantExpression.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | using System; 18 | 19 | namespace Apache.NMS.Selector 20 | { 21 | /// 22 | /// Represents a boolean constant expression. 23 | /// 24 | public class BooleanConstantExpression : ConstantExpression, IBooleanExpression 25 | { 26 | public BooleanConstantExpression(object value) 27 | : base(value) 28 | { 29 | } 30 | 31 | public bool Matches(MessageEvaluationContext message) 32 | { 33 | object value = Evaluate(message); 34 | return value != null && (bool)value; 35 | } 36 | } 37 | } -------------------------------------------------------------------------------- /src/main/csharp/Selector/IBooleanExpression.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | using System; 18 | 19 | namespace Apache.NMS.Selector 20 | { 21 | /// 22 | /// An IBooleanExpression is an expression that always 23 | /// produces a boolean result. 24 | /// 25 | public interface IBooleanExpression : IExpression 26 | { 27 | /// 28 | /// Checks if expression evaluates to true. 29 | /// 30 | /// Evaluation context. 31 | /// true if the expression evaluates to true. 32 | bool Matches(MessageEvaluationContext message); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/test/csharp/MSMQMessageTest.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | using System; 18 | using Apache.NMS.Test; 19 | using NUnit.Framework; 20 | 21 | namespace Apache.NMS.MSMQ.Test 22 | { 23 | [TestFixture] 24 | public class MSMQMessageTest : MessageTest 25 | { 26 | protected static string DEFAULT_TEST_QUEUE = "defaultTestQueue"; 27 | 28 | public MSMQMessageTest() 29 | : base(new MSMQTestSupport()) 30 | { 31 | } 32 | 33 | [Test] 34 | public void TestSendReceiveMessageProperties( 35 | [Values(MsgDeliveryMode.Persistent, MsgDeliveryMode.NonPersistent)] 36 | MsgDeliveryMode deliveryMode) 37 | { 38 | base.TestSendReceiveMessageProperties(deliveryMode, DEFAULT_TEST_QUEUE); 39 | } 40 | } 41 | } 42 | 43 | -------------------------------------------------------------------------------- /src/test/csharp/MSMQNMSPropertyTest.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | using System; 18 | using Apache.NMS.Test; 19 | using NUnit.Framework; 20 | 21 | namespace Apache.NMS.MSMQ.Test 22 | { 23 | [TestFixture] 24 | public class MSMQNMSPropertyTest : NMSPropertyTest 25 | { 26 | protected static string DEFAULT_TEST_QUEUE = "defaultTestQueue"; 27 | 28 | public MSMQNMSPropertyTest() 29 | : base(new MSMQTestSupport()) 30 | { 31 | } 32 | 33 | [Test] 34 | public void TestSendReceiveNMSProperties( 35 | [Values(MsgDeliveryMode.Persistent, MsgDeliveryMode.NonPersistent)] 36 | MsgDeliveryMode deliveryMode) 37 | { 38 | base.TestSendReceiveNMSProperties(deliveryMode, DEFAULT_TEST_QUEUE); 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/test/csharp/MSMQTextMessageTest.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | using System; 18 | using Apache.NMS.Test; 19 | using NUnit.Framework; 20 | 21 | namespace Apache.NMS.MSMQ.Test 22 | { 23 | [TestFixture] 24 | public class MSMQTextMessageTest : TextMessageTest 25 | { 26 | protected static string DEFAULT_TEST_QUEUE = "defaultTestQueue"; 27 | 28 | public MSMQTextMessageTest() 29 | : base(new MSMQTestSupport()) 30 | { 31 | } 32 | 33 | [Test] 34 | public void TestSendReceiveTextMessage( 35 | [Values(MsgDeliveryMode.Persistent, MsgDeliveryMode.NonPersistent)] 36 | MsgDeliveryMode deliveryMode) 37 | { 38 | base.TestSendReceiveTextMessage(deliveryMode, DEFAULT_TEST_QUEUE); 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/test/csharp/MSMQStreamMessageTest.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | using System; 18 | using Apache.NMS.Test; 19 | using NUnit.Framework; 20 | 21 | namespace Apache.NMS.MSMQ.Test 22 | { 23 | [TestFixture] 24 | public class MSMQStreamMessageTest : StreamMessageTest 25 | { 26 | protected static string DEFAULT_TEST_QUEUE = "defaultTestQueue"; 27 | 28 | public MSMQStreamMessageTest() 29 | : base(new MSMQTestSupport()) 30 | { 31 | } 32 | 33 | [Test] 34 | public void TestSendReceiveStreamMessage( 35 | [Values(MsgDeliveryMode.Persistent, MsgDeliveryMode.NonPersistent)] 36 | MsgDeliveryMode deliveryMode) 37 | { 38 | base.TestSendReceiveStreamMessage(deliveryMode, DEFAULT_TEST_QUEUE); 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/test/csharp/MSMQRequestResponseTest.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | using System; 18 | using Apache.NMS.Test; 19 | using NUnit.Framework; 20 | 21 | namespace Apache.NMS.MSMQ.Test 22 | { 23 | [TestFixture] 24 | public class MSMQRequestResponseTest : RequestResponseTest 25 | { 26 | protected const string DEFAULT_TEST_QUEUE = "defaultTestQueue"; 27 | protected const string DEFAULT_TEST_QUEUE2 = "defaultTestQueue2"; 28 | 29 | public MSMQRequestResponseTest() 30 | : base(new MSMQTestSupport()) 31 | { 32 | } 33 | 34 | [Test] 35 | [Category("RequestResponse")] 36 | public void TestRequestResponseMessaging() 37 | { 38 | base.TestRequestResponseMessaging(DEFAULT_TEST_QUEUE, DEFAULT_TEST_QUEUE2); 39 | } 40 | } 41 | } 42 | 43 | -------------------------------------------------------------------------------- /src/test/csharp/MSMQBadConsumeTest.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | using System; 18 | using NUnit.Framework; 19 | using Apache.NMS.Test; 20 | 21 | namespace Apache.NMS.MSMQ.Test 22 | { 23 | [TestFixture] 24 | public class MSMQBadConsumeTest : BadConsumeTest 25 | { 26 | public MSMQBadConsumeTest() 27 | : base(new MSMQTestSupport()) 28 | { 29 | } 30 | 31 | [SetUp] 32 | public override void SetUp() 33 | { 34 | base.SetUp(); 35 | } 36 | 37 | [TearDown] 38 | public override void TearDown() 39 | { 40 | base.TearDown(); 41 | } 42 | 43 | [Test] 44 | [ExpectedException(Handler="ExceptionValidationCheck")] 45 | public override void TestBadConsumerException() 46 | { 47 | base.TestBadConsumerException(); 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/main/csharp/Selector/BooleanUnaryExpression.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | using System; 18 | 19 | namespace Apache.NMS.Selector 20 | { 21 | /// 22 | /// An expression which performs an operation on one expression value 23 | /// and returns a boolean value. 24 | /// 25 | public abstract class BooleanUnaryExpression : UnaryExpression, IBooleanExpression 26 | { 27 | public BooleanUnaryExpression(IExpression left) 28 | : base(left) 29 | { 30 | } 31 | 32 | public bool Matches(MessageEvaluationContext message) 33 | { 34 | object value = Evaluate(message); 35 | return value != null && (bool)value; 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/main/csharp/Selector/LesserExpression.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | using System; 18 | 19 | namespace Apache.NMS.Selector 20 | { 21 | /// 22 | /// A filter performing a lesser than comparison of two expressions. 23 | /// 24 | public class LesserExpression : ComparisonExpression 25 | { 26 | protected override string ExpressionSymbol 27 | { 28 | get { return "<"; } 29 | } 30 | 31 | public LesserExpression(IExpression left, IExpression right) 32 | : base(left, right) 33 | { 34 | } 35 | 36 | public override bool AsBoolean(int? compared) 37 | { 38 | return compared.HasValue ? compared.Value < 0 : false; 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/csharp/Selector/GreaterExpression.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | using System; 18 | 19 | namespace Apache.NMS.Selector 20 | { 21 | /// 22 | /// A filter performing a greater than comparison of two expressions. 23 | /// 24 | public class GreaterExpression : ComparisonExpression 25 | { 26 | protected override string ExpressionSymbol 27 | { 28 | get { return ">"; } 29 | } 30 | 31 | public GreaterExpression(IExpression left, IExpression right) 32 | : base(left, right) 33 | { 34 | } 35 | 36 | public override bool AsBoolean(int? compared) 37 | { 38 | return compared.HasValue ? compared.Value > 0 : false; 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /vs2008-msmq.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2008 4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "vs2008-msmq", "vs2008-msmq.csproj", "{A5FCA129-991B-4CB2-987A-B25E43B0F5EC}" 5 | EndProject 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "vs2008-msmq-test", "vs2008-msmq-test.csproj", "{2F31ED5C-44A2-464A-BD55-2B5B010654E8}" 7 | EndProject 8 | Global 9 | GlobalSection(SubversionScc) = preSolution 10 | Svn-Managed = True 11 | Manager = AnkhSVN - Subversion Support for Visual Studio 12 | EndGlobalSection 13 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 14 | Debug|Any CPU = Debug|Any CPU 15 | Release|Any CPU = Release|Any CPU 16 | EndGlobalSection 17 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 18 | {A5FCA129-991B-4CB2-987A-B25E43B0F5EC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 19 | {A5FCA129-991B-4CB2-987A-B25E43B0F5EC}.Debug|Any CPU.Build.0 = Debug|Any CPU 20 | {A5FCA129-991B-4CB2-987A-B25E43B0F5EC}.Release|Any CPU.ActiveCfg = Release|Any CPU 21 | {A5FCA129-991B-4CB2-987A-B25E43B0F5EC}.Release|Any CPU.Build.0 = Release|Any CPU 22 | {2F31ED5C-44A2-464A-BD55-2B5B010654E8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 23 | {2F31ED5C-44A2-464A-BD55-2B5B010654E8}.Debug|Any CPU.Build.0 = Debug|Any CPU 24 | {2F31ED5C-44A2-464A-BD55-2B5B010654E8}.Release|Any CPU.ActiveCfg = Release|Any CPU 25 | {2F31ED5C-44A2-464A-BD55-2B5B010654E8}.Release|Any CPU.Build.0 = Release|Any CPU 26 | EndGlobalSection 27 | GlobalSection(SolutionProperties) = preSolution 28 | HideSolutionNode = FALSE 29 | EndGlobalSection 30 | EndGlobal 31 | -------------------------------------------------------------------------------- /src/main/csharp/Selector/LesserOrEqualExpression.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | using System; 18 | 19 | namespace Apache.NMS.Selector 20 | { 21 | /// 22 | /// A filter performing a lesser than or equal comparison 23 | /// of two expressions. 24 | /// 25 | public class LesserOrEqualExpression : ComparisonExpression 26 | { 27 | protected override string ExpressionSymbol 28 | { 29 | get { return "<="; } 30 | } 31 | 32 | public LesserOrEqualExpression(IExpression left, IExpression right) 33 | : base(left, right) 34 | { 35 | } 36 | 37 | public override bool AsBoolean(int? compared) 38 | { 39 | return compared.HasValue ? compared.Value <= 0 : false; 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/csharp/Selector/GreaterOrEqualExpression.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | using System; 18 | 19 | namespace Apache.NMS.Selector 20 | { 21 | /// 22 | /// A filter performing a greater than or equal comparison 23 | /// of two expressions. 24 | /// 25 | public class GreaterOrEqualExpression : ComparisonExpression 26 | { 27 | protected override string ExpressionSymbol 28 | { 29 | get { return ">="; } 30 | } 31 | 32 | public GreaterOrEqualExpression(IExpression left, IExpression right) 33 | : base(left, right) 34 | { 35 | } 36 | 37 | public override bool AsBoolean(int? compared) 38 | { 39 | return compared.HasValue ? compared.Value >= 0 : false; 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /msmqprovider-test.config: -------------------------------------------------------------------------------- 1 | 2 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /src/test/csharp/MSMQXmlMessageTest.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | using System; 18 | using Apache.NMS.Test; 19 | using NUnit.Framework; 20 | 21 | namespace Apache.NMS.MSMQ.Test 22 | { 23 | [TestFixture] 24 | public class MSMQXmlMessageTest : XmlMessageTest 25 | { 26 | protected static string DEFAULT_TEST_QUEUE = "defaultTestQueue"; 27 | 28 | public MSMQXmlMessageTest() 29 | : base(new MSMQTestSupport()) 30 | { 31 | } 32 | 33 | #if NET_3_5 || MONO 34 | 35 | [Test] 36 | public void TestSendReceiveXmlMessage_Net35() 37 | { 38 | base.TestSendReceiveXmlMessage_Net35(DEFAULT_TEST_QUEUE); 39 | } 40 | 41 | #else 42 | 43 | // Test the obsolete API versions until they are completely removed. 44 | [Test] 45 | public void SendReceiveXmlMessage() 46 | { 47 | base.TestSendReceiveXmlMessage(DEFAULT_TEST_QUEUE); 48 | } 49 | 50 | #endif 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/main/csharp/Selector/NOTExpression.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | using System; 18 | 19 | namespace Apache.NMS.Selector 20 | { 21 | /// 22 | /// An expression which negates a boolean expression value. 23 | /// 24 | public class NOTExpression : BooleanUnaryExpression 25 | { 26 | protected override string ExpressionSymbol 27 | { 28 | get { return "NOT"; } 29 | } 30 | 31 | public NOTExpression(IExpression left) 32 | : base(left) 33 | { 34 | } 35 | 36 | public override object Evaluate(MessageEvaluationContext message) 37 | { 38 | object rvalue = Right.Evaluate(message); 39 | if(rvalue == null ) return null; 40 | if(rvalue is bool ) return !(bool)rvalue; 41 | return null; 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main/csharp/Selector/BooleanCastExpression.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | using System; 18 | 19 | namespace Apache.NMS.Selector 20 | { 21 | /// 22 | /// An expression which casts an expression value to a boolean. 23 | /// 24 | public class BooleanCastExpression : BooleanUnaryExpression 25 | { 26 | protected override string ExpressionSymbol 27 | { 28 | get { return ""; } 29 | } 30 | 31 | public BooleanCastExpression(IExpression left) 32 | : base(left) 33 | { 34 | } 35 | 36 | public override object Evaluate(MessageEvaluationContext message) 37 | { 38 | object rvalue = Right.Evaluate(message); 39 | if(rvalue == null ) return null; 40 | if(rvalue is bool ) return (bool)rvalue; 41 | return false; 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/test/csharp/MSMQMessageTransformerTest.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | using System; 18 | using Apache.NMS.Test; 19 | using NUnit.Framework; 20 | 21 | namespace Apache.NMS.MSMQ.Test 22 | { 23 | [TestFixture] 24 | public class MSMQMessageTransformerTest : MessageTransformerTest 25 | { 26 | public MSMQMessageTransformerTest() 27 | : base(new MSMQTestSupport()) 28 | { 29 | } 30 | 31 | [Test] 32 | public override void TestProducerTransformer( 33 | [Values(MsgDeliveryMode.Persistent, MsgDeliveryMode.NonPersistent)] 34 | MsgDeliveryMode deliveryMode) 35 | { 36 | base.TestProducerTransformer(deliveryMode); 37 | } 38 | 39 | [Test] 40 | public override void TestConsumerTransformer( 41 | [Values(MsgDeliveryMode.Persistent, MsgDeliveryMode.NonPersistent)] 42 | MsgDeliveryMode deliveryMode) 43 | { 44 | base.TestConsumerTransformer(deliveryMode); 45 | } 46 | } 47 | } 48 | 49 | -------------------------------------------------------------------------------- /src/main/csharp/Selector/PropertyExpression.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | using System; 18 | 19 | namespace Apache.NMS.Selector 20 | { 21 | /// 22 | /// Represents a property expression. 23 | /// 24 | public class PropertyExpression : IExpression 25 | { 26 | private string name; 27 | public string Name 28 | { 29 | get { return name; } 30 | } 31 | 32 | public PropertyExpression(string name) 33 | { 34 | this.name = name; 35 | } 36 | 37 | public object Evaluate(MessageEvaluationContext message) 38 | { 39 | return message.GetProperty(name); 40 | } 41 | 42 | public override string ToString() 43 | { 44 | return name; 45 | } 46 | 47 | public override int GetHashCode() 48 | { 49 | return name.GetHashCode(); 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/main/csharp/Selector/EqualExpression.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | using System; 18 | 19 | namespace Apache.NMS.Selector 20 | { 21 | /// 22 | /// A filter performing an equality or inequality comparison 23 | /// of two expressions. 24 | /// 25 | public class EqualExpression : ComparisonExpression 26 | { 27 | private bool notNot; 28 | 29 | protected override string ExpressionSymbol 30 | { 31 | get { return notNot ? "=" : "<>"; } 32 | } 33 | 34 | public EqualExpression(IExpression left, IExpression right, bool notNot) 35 | : base(left, right) 36 | { 37 | this.notNot = notNot; 38 | } 39 | 40 | public override bool AsBoolean(int? compared) 41 | { 42 | bool answer = (compared.HasValue ? compared.Value == 0 : false); 43 | return notNot ? answer : !answer; 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/main/csharp/Selector/ORExpression.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | using System; 18 | 19 | namespace Apache.NMS.Selector 20 | { 21 | /// 22 | /// A filter performing a logical OR combination of two expressions. 23 | /// 24 | public class ORExpression : LogicExpression 25 | { 26 | protected override string ExpressionSymbol 27 | { 28 | get { return "OR"; } 29 | } 30 | 31 | public ORExpression(IBooleanExpression left, IBooleanExpression right) 32 | : base(left, right) 33 | { 34 | } 35 | 36 | public override object Evaluate(MessageEvaluationContext message) 37 | { 38 | object lvalue = Left.Evaluate(message); 39 | if(lvalue != null && (bool)lvalue) return true; 40 | 41 | object rvalue = Right.Evaluate(message); 42 | return rvalue == null ? null : rvalue; 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/main/csharp/Selector/ANDExpression.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | using System; 18 | 19 | namespace Apache.NMS.Selector 20 | { 21 | /// 22 | /// A filter performing a logical AND combination of two expressions. 23 | /// 24 | public class ANDExpression : LogicExpression 25 | { 26 | protected override string ExpressionSymbol 27 | { 28 | get { return "AND"; } 29 | } 30 | 31 | public ANDExpression(IBooleanExpression left, IBooleanExpression right) 32 | : base(left, right) 33 | { 34 | } 35 | 36 | public override object Evaluate(MessageEvaluationContext message) 37 | { 38 | object lvalue = Left.Evaluate(message); 39 | if(lvalue == null) return null; 40 | if(!(bool)lvalue) return false; 41 | 42 | object rvalue = Right.Evaluate(message); 43 | return rvalue == null ? null : rvalue; 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/main/sandcastle/feedback_content.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | activemq.docs@apache.org 4 | 5 | 6 | 7 | Customer%20Feedback 8 | %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 9 | 10 | Send Feedback 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | We value your feedback. To rate this topic and send feedback about this topic to the documentation team, click a rating, and then click Send Feedback. For assistance with support issues, refer to the technical support information included with the product. 24 | 25 | Send Feedback 26 | Poor 27 | Outstanding 28 | To e-mail your feedback, click here: 29 | Documentation Feedback 30 | Display feedback instructions at the bottom of the page. 31 | 32 | -------------------------------------------------------------------------------- /src/test/csharp/MSMQTestSupport.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | using System; 18 | using System.Xml; 19 | using Apache.NMS.Test; 20 | using Apache.NMS.Util; 21 | using NUnit.Framework; 22 | 23 | using Apache.NMS.MSMQ; 24 | 25 | namespace Apache.NMS.MSMQ.Test 26 | { 27 | /// 28 | /// Useful class for test cases support. 29 | /// 30 | public class MSMQTestSupport : NMSTestSupport 31 | { 32 | /// 33 | /// Gets the environment variable name for the configuration file path. 34 | /// 35 | /// Environment variable name 36 | public override string GetConfigEnvVarName() 37 | { 38 | return "MSMQTESTCONFIGPATH"; 39 | } 40 | 41 | /// 42 | /// Gets the default name for the configuration filename. 43 | /// 44 | /// Default name of the configuration filename 45 | public override string GetDefaultConfigFileName() 46 | { 47 | return "msmqprovider-test.config"; 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/test/csharp/MSMQBytesMessageTest.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | using System; 19 | using Apache.NMS.Util; 20 | using Apache.NMS.Test; 21 | using NUnit.Framework; 22 | 23 | namespace Apache.NMS.MSMQ.Test 24 | { 25 | [TestFixture] 26 | public class MSMQBytesMessageTest : BytesMessageTest 27 | { 28 | protected static string DEFAULT_TEST_QUEUE = "defaultTestQueue"; 29 | 30 | public MSMQBytesMessageTest() 31 | : base(new MSMQTestSupport()) 32 | { 33 | } 34 | 35 | [Test] 36 | public void SendReceiveBytesMessage( 37 | [Values(MsgDeliveryMode.Persistent, MsgDeliveryMode.NonPersistent)] 38 | MsgDeliveryMode deliveryMode) 39 | { 40 | base.SendReceiveBytesMessage(deliveryMode, DEFAULT_TEST_QUEUE); 41 | } 42 | 43 | [Test] 44 | public void SendReceiveBytesMessageContent( 45 | [Values(MsgDeliveryMode.Persistent, MsgDeliveryMode.NonPersistent)] 46 | MsgDeliveryMode deliveryMode) 47 | { 48 | base.SendReceiveBytesMessageContent(deliveryMode, DEFAULT_TEST_QUEUE); 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/test/csharp/MSMQMapMessageTest.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | using System; 18 | using Apache.NMS.Test; 19 | using NUnit.Framework; 20 | 21 | namespace Apache.NMS.MSMQ.Test 22 | { 23 | [TestFixture] 24 | public class MSMQMapMessageTest : MapMessageTest 25 | { 26 | protected static string DEFAULT_TEST_QUEUE = "defaultTestQueue"; 27 | 28 | public MSMQMapMessageTest() 29 | : base(new MSMQTestSupport()) 30 | { 31 | } 32 | 33 | [Test] 34 | public void TestSendReceiveMapMessage( 35 | [Values(MsgDeliveryMode.Persistent, MsgDeliveryMode.NonPersistent)] 36 | MsgDeliveryMode deliveryMode) 37 | { 38 | base.TestSendReceiveMapMessage(deliveryMode, DEFAULT_TEST_QUEUE); 39 | } 40 | 41 | [Test] 42 | public void TestSendReceiveNestedMapMessage( 43 | [Values(MsgDeliveryMode.Persistent, MsgDeliveryMode.NonPersistent)] 44 | MsgDeliveryMode deliveryMode) 45 | { 46 | base.TestSendReceiveNestedMapMessage(deliveryMode, DEFAULT_TEST_QUEUE); 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/main/csharp/Selector/LogicExpression.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | using System; 18 | 19 | namespace Apache.NMS.Selector 20 | { 21 | /// 22 | /// A filter performing a logical combination of two objects. 23 | /// 24 | public abstract class LogicExpression : BinaryExpression, IBooleanExpression 25 | { 26 | public LogicExpression(IBooleanExpression left, IBooleanExpression right) 27 | : base(left, right) 28 | { 29 | } 30 | 31 | public bool Matches(MessageEvaluationContext message) 32 | { 33 | object value = Evaluate(message); 34 | return value != null && (bool)value; 35 | } 36 | 37 | public static IBooleanExpression CreateOR(IBooleanExpression left, IBooleanExpression right) 38 | { 39 | return new ORExpression(left, right); 40 | } 41 | 42 | public static IBooleanExpression CreateAND(IBooleanExpression left, IBooleanExpression right) 43 | { 44 | return new ANDExpression(left, right); 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/main/csharp/Selector/SelectorParserConstants.cs: -------------------------------------------------------------------------------- 1 | /* Generated By:CSharpCC: Do not edit this line. SelectorParserConstants.cs */ 2 | public class SelectorParserConstants { 3 | 4 | public const int EOF = 0; 5 | public const int LINE_COMMENT = 6; 6 | public const int BLOCK_COMMENT = 7; 7 | public const int NOT = 8; 8 | public const int AND = 9; 9 | public const int OR = 10; 10 | public const int BETWEEN = 11; 11 | public const int LIKE = 12; 12 | public const int ESCAPE = 13; 13 | public const int IN = 14; 14 | public const int IS = 15; 15 | public const int TRUE = 16; 16 | public const int FALSE = 17; 17 | public const int NULL = 18; 18 | public const int XPATH = 19; 19 | public const int XQUERY = 20; 20 | public const int DECIMAL_LITERAL = 21; 21 | public const int HEX_LITERAL = 22; 22 | public const int OCTAL_LITERAL = 23; 23 | public const int FLOATING_POINT_LITERAL = 24; 24 | public const int EXPONENT = 25; 25 | public const int STRING_LITERAL = 26; 26 | public const int ID = 27; 27 | 28 | public const int DEFAULT = 0; 29 | 30 | public readonly string[] tokenImage = { 31 | "", 32 | "\" \"", 33 | "\"\\t\"", 34 | "\"\\n\"", 35 | "\"\\r\"", 36 | "\"\\f\"", 37 | "", 38 | "", 39 | "\"NOT\"", 40 | "\"AND\"", 41 | "\"OR\"", 42 | "\"BETWEEN\"", 43 | "\"LIKE\"", 44 | "\"ESCAPE\"", 45 | "\"IN\"", 46 | "\"IS\"", 47 | "\"TRUE\"", 48 | "\"FALSE\"", 49 | "\"NULL\"", 50 | "\"XPATH\"", 51 | "\"XQUERY\"", 52 | "", 53 | "", 54 | "", 55 | "", 56 | "", 57 | "", 58 | "", 59 | "\"=\"", 60 | "\"<>\"", 61 | "\">\"", 62 | "\">=\"", 63 | "\"<\"", 64 | "\"<=\"", 65 | "\"(\"", 66 | "\",\"", 67 | "\")\"", 68 | "\"+\"", 69 | "\"-\"", 70 | "\"*\"", 71 | "\"/\"", 72 | "\"%\"", 73 | }; 74 | 75 | } 76 | -------------------------------------------------------------------------------- /src/main/csharp/IMessageConverter.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | using System.Messaging; 18 | 19 | namespace Apache.NMS.MSMQ 20 | { 21 | public interface IMessageConverter 22 | { 23 | /// 24 | /// Converts the specified NMS message to an equivalent MSMQ message. 25 | /// 26 | /// NMS message to be converted. 27 | /// Converted MSMQ message. 28 | Message ToMsmqMessage(IMessage message); 29 | 30 | /// 31 | /// Converts the specified MSMQ message to an equivalent NMS message 32 | /// (including its message body). 33 | /// 34 | /// MSMQ message to be converted. 35 | /// Converted NMS message. 36 | IMessage ToNmsMessage(Message message); 37 | 38 | /// 39 | /// Converts an NMS destination to the equivalent MSMQ destination 40 | /// (ie. queue). 41 | /// 42 | /// NMS destination. 43 | /// MSMQ queue. 44 | MessageQueue ToMsmqDestination(IDestination destination); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/test/csharp/MSMQTempDestinationDeletionTest.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | using System; 18 | using Apache.NMS.Util; 19 | using Apache.NMS.Test; 20 | using NUnit.Framework; 21 | 22 | namespace Apache.NMS.MSMQ.Test 23 | { 24 | [TestFixture] 25 | [Ignore("Temporary queues are not supported")] 26 | public class MSMQTempDestinationDeletionTest : TempDestinationDeletionTest 27 | { 28 | protected const string DELETION_TEST_QUEUE = "deletionTestQueue"; 29 | protected const string DELETION_TEST_TOPIC = "deletionTestTopic"; 30 | protected const string DELETION_TEST_TEMP_QUEUE = "deletionTestTempQueue"; 31 | protected const string DELETION_TEST_TEMP_TOPIC = "deletionTestTempTopic"; 32 | 33 | public MSMQTempDestinationDeletionTest() 34 | : base(new MSMQTestSupport()) 35 | { 36 | } 37 | 38 | [Test] 39 | public override void TestTempDestinationDeletion( 40 | [Values(MsgDeliveryMode.Persistent, MsgDeliveryMode.NonPersistent)] 41 | MsgDeliveryMode deliveryMode, 42 | [Values(DELETION_TEST_QUEUE, DELETION_TEST_TOPIC, DELETION_TEST_TEMP_QUEUE, DELETION_TEST_TEMP_TOPIC)] 43 | string testDestRef) 44 | { 45 | base.TestTempDestinationDeletion(deliveryMode, testDestRef); 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/main/csharp/Selector/NegateExpression.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | using System; 18 | 19 | namespace Apache.NMS.Selector 20 | { 21 | /// 22 | /// An expression which negates a numeric expression value. 23 | /// 24 | public class NegateExpression : UnaryExpression 25 | { 26 | protected override string ExpressionSymbol 27 | { 28 | get { return "-"; } 29 | } 30 | 31 | public NegateExpression(IExpression left) 32 | : base(left) 33 | { 34 | } 35 | 36 | public override object Evaluate(MessageEvaluationContext message) 37 | { 38 | object rvalue = Right.Evaluate(message); 39 | if(rvalue == null ) return null; 40 | if(rvalue is int ) return -(int )rvalue; 41 | if(rvalue is long ) return -(long )rvalue; 42 | if(rvalue is double ) return -(double )rvalue; 43 | if(rvalue is float ) return -(float )rvalue; 44 | if(rvalue is decimal) return -(decimal)rvalue; 45 | if(rvalue is short ) return -(short )rvalue; 46 | if(rvalue is byte ) return -(byte )rvalue; 47 | return null; 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/main/csharp/IMessageConverterEx.cs: -------------------------------------------------------------------------------- 1 | using System.Messaging; 2 | /* 3 | * Licensed to the Apache Software Foundation (ASF) under one or more 4 | * contributor license agreements. See the NOTICE file distributed with 5 | * this work for additional information regarding copyright ownership. 6 | * The ASF licenses this file to You under the Apache License, Version 2.0 7 | * (the "License"); you may not use this file except in compliance with 8 | * the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | namespace Apache.NMS.MSMQ 20 | { 21 | /// 22 | /// Extended IMessageConverter interface supporting new methods for 23 | /// optimizing message selection through "selectors". 24 | /// The original IMessageConverter is maintained for compatibility 25 | /// reasons with existing clients implementing it. 26 | /// 27 | public interface IMessageConverterEx : IMessageConverter 28 | { 29 | /// 30 | /// Converts the specified MSMQ message to an equivalent NMS message. 31 | /// 32 | /// MSMQ message to be converted. 33 | /// true if message body should be converted. 34 | /// Converted NMS message. 35 | IMessage ToNmsMessage(Message message, bool convertBody); 36 | 37 | /// 38 | /// Converts an MSMQ message body to the equivalent NMS message body. 39 | /// 40 | /// Source MSMQ message. 41 | /// Target NMS message. 42 | void ConvertMessageBodyToNMS(Message message, IMessage answer); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/test/csharp/BadConsumeTest.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | using System; 18 | using NUnit.Framework; 19 | 20 | namespace Apache.NMS.Test 21 | { 22 | //[TestFixture] 23 | public class BadConsumeTest : NMSTest 24 | { 25 | protected IConnection connection; 26 | protected ISession session; 27 | 28 | protected BadConsumeTest(NMSTestSupport testSupport) 29 | : base(testSupport) 30 | { 31 | } 32 | 33 | //[SetUp] 34 | public override void SetUp() 35 | { 36 | connection = CreateConnection(GetTestClientId()); 37 | connection.Start(); 38 | session = connection.CreateSession(AcknowledgementMode.AutoAcknowledge); 39 | } 40 | 41 | //[TearDown] 42 | public override void TearDown() 43 | { 44 | if(null != session) 45 | { 46 | session.Dispose(); 47 | session = null; 48 | } 49 | 50 | if(null != connection) 51 | { 52 | connection.Dispose(); 53 | connection = null; 54 | } 55 | } 56 | 57 | //[Test] 58 | //[ExpectedException(Handler="ExceptionValidationCheck")] 59 | public virtual void TestBadConsumerException() 60 | { 61 | session.CreateConsumer(null); 62 | } 63 | 64 | public void ExceptionValidationCheck(Exception ex) 65 | { 66 | Assert.IsNotNull(ex as NMSException, "Invalid exception was thrown."); 67 | } 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /src/main/csharp/Selector/IsNullExpression.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | using System; 18 | using System.Text; 19 | 20 | namespace Apache.NMS.Selector 21 | { 22 | /// 23 | /// A boolean expression which checks if an expression value is null. 24 | /// 25 | public class IsNullExpression : BooleanUnaryExpression 26 | { 27 | private bool notNot; 28 | 29 | protected override string ExpressionSymbol 30 | { 31 | get { return notNot ? "IS NULL" : "IS NOT NULL"; } 32 | } 33 | 34 | public IsNullExpression(IExpression right, bool notNot) 35 | : base(right) 36 | { 37 | this.notNot = notNot; 38 | } 39 | 40 | public override object Evaluate(MessageEvaluationContext message) 41 | { 42 | object rvalue = Right.Evaluate(message); 43 | 44 | bool answer = (rvalue == null || rvalue == ConstantExpression.NULL); 45 | 46 | return notNot ? answer : !answer; 47 | } 48 | 49 | public override string ToString() 50 | { 51 | StringBuilder answer = new StringBuilder(); 52 | answer.Append(Right); 53 | answer.Append(" "); 54 | answer.Append(ExpressionSymbol); 55 | return answer.ToString(); 56 | } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/main/csharp/Selector/BinaryExpression.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | using System; 18 | 19 | namespace Apache.NMS.Selector 20 | { 21 | /// 22 | /// An expression which performs an operation on two expression values. 23 | /// 24 | public abstract class BinaryExpression : IExpression 25 | { 26 | protected IExpression leftExpression; 27 | public IExpression Left 28 | { 29 | get { return leftExpression; } 30 | set { leftExpression = value; } 31 | } 32 | 33 | protected IExpression rightExpression; 34 | public IExpression Right 35 | { 36 | get { return rightExpression; } 37 | set { rightExpression = value; } 38 | } 39 | 40 | protected abstract string ExpressionSymbol 41 | { 42 | get; 43 | } 44 | 45 | public BinaryExpression(IExpression left, IExpression right) 46 | { 47 | leftExpression = left; 48 | rightExpression = right; 49 | } 50 | 51 | public abstract object Evaluate(MessageEvaluationContext message); 52 | 53 | public override string ToString() 54 | { 55 | return "(" + leftExpression.ToString() + " " + ExpressionSymbol + " " + rightExpression.ToString() + ")"; 56 | } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/test/csharp/Commands/TextMessage.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | using System; 19 | using System.IO; 20 | 21 | using Apache.NMS; 22 | using Apache.NMS.Util; 23 | 24 | namespace Apache.NMS.Commands 25 | { 26 | public class TextMessage : Message, ITextMessage 27 | { 28 | private String text = null; 29 | 30 | public TextMessage() 31 | { 32 | } 33 | 34 | public TextMessage(String text) 35 | { 36 | this.Text = text; 37 | } 38 | 39 | public override string ToString() 40 | { 41 | string text = this.Text; 42 | 43 | if(text != null && text.Length > 63) 44 | { 45 | text = text.Substring(0, 45) + "..." + text.Substring(text.Length - 12); 46 | } 47 | return base.ToString() + " Text = " + (text ?? "null"); 48 | } 49 | 50 | public override void ClearBody() 51 | { 52 | base.ClearBody(); 53 | this.text = null; 54 | } 55 | 56 | // Properties 57 | 58 | public string Text 59 | { 60 | get { return this.text; } 61 | set 62 | { 63 | FailIfReadOnlyBody(); 64 | this.text = value; 65 | this.Content = null; 66 | } 67 | } 68 | } 69 | } 70 | 71 | -------------------------------------------------------------------------------- /src/main/csharp/Selector/ArithmeticExpression.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | using System; 18 | 19 | namespace Apache.NMS.Selector 20 | { 21 | /// 22 | /// An expression which performs an operation on two expression values. 23 | /// 24 | public abstract class ArithmeticExpression : BinaryExpression 25 | { 26 | public ArithmeticExpression(IExpression left, IExpression right) 27 | : base(left, right) 28 | { 29 | } 30 | 31 | public static IExpression CreatePlus(IExpression left, IExpression right) 32 | { 33 | return new PlusExpression(left, right); 34 | } 35 | 36 | public static IExpression CreateMinus(IExpression left, IExpression right) 37 | { 38 | return new MinusExpression(left, right); 39 | } 40 | 41 | public static IExpression CreateMultiply(IExpression left, IExpression right) 42 | { 43 | return new MultiplyExpression(left, right); 44 | } 45 | 46 | public static IExpression CreateDivide(IExpression left, IExpression right) 47 | { 48 | return new DivideExpression(left, right); 49 | } 50 | 51 | public static IExpression CreateMod(IExpression left, IExpression right) 52 | { 53 | return new ModExpression(left, right); 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/main/csharp/ObjectMessage.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | using System.IO; 19 | 20 | #if !(PocketPC||NETCF||NETCF_2_0) 21 | using System.Runtime.Serialization; 22 | using System.Runtime.Serialization.Formatters.Binary; 23 | #endif 24 | 25 | namespace Apache.NMS.MSMQ 26 | { 27 | public class ObjectMessage : BaseMessage, IObjectMessage 28 | { 29 | private object body; 30 | #if !(PocketPC||NETCF||NETCF_2_0) 31 | private IFormatter formatter; 32 | #endif 33 | 34 | public ObjectMessage() 35 | { 36 | } 37 | 38 | public ObjectMessage(object body) 39 | { 40 | this.body = body; 41 | } 42 | 43 | public object Body 44 | { 45 | get 46 | { 47 | #if !(PocketPC||NETCF||NETCF_2_0) 48 | if(body == null) 49 | { 50 | body = Formatter.Deserialize(new MemoryStream(Content)); 51 | } 52 | #else 53 | #endif 54 | return body; 55 | } 56 | 57 | set 58 | { 59 | #if !(PocketPC||NETCF||NETCF_2_0) 60 | body = value; 61 | #else 62 | throw new NotImplementedException(); 63 | #endif 64 | } 65 | } 66 | 67 | 68 | #if !(PocketPC||NETCF||NETCF_2_0) 69 | public IFormatter Formatter 70 | { 71 | get 72 | { 73 | if(formatter == null) 74 | { 75 | formatter = new BinaryFormatter(); 76 | } 77 | return formatter; 78 | } 79 | 80 | set 81 | { 82 | formatter = value; 83 | } 84 | } 85 | 86 | #endif 87 | } 88 | } 89 | 90 | 91 | 92 | 93 | 94 | 95 | -------------------------------------------------------------------------------- /src/test/csharp/MSMQTempDestinationTest.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | using System; 18 | using Apache.NMS.Test; 19 | using NUnit.Framework; 20 | 21 | namespace Apache.NMS.MSMQ.Test 22 | { 23 | [TestFixture] 24 | [Ignore("Temporary queues are not supported")] 25 | public class MSMQTempDestinationTest : TempDestinationTest 26 | { 27 | public MSMQTempDestinationTest() 28 | : base(new MSMQTestSupport()) 29 | { 30 | } 31 | 32 | [SetUp] 33 | public override void SetUp() 34 | { 35 | base.SetUp(); 36 | } 37 | 38 | [TearDown] 39 | public override void TearDown() 40 | { 41 | base.TearDown(); 42 | } 43 | 44 | [Test] 45 | public override void TestTempDestOnlyConsumedByLocalConn() 46 | { 47 | base.TestTempDestOnlyConsumedByLocalConn(); 48 | } 49 | 50 | [Test] 51 | public override void TestTempQueueHoldsMessagesWithConsumers() 52 | { 53 | base.TestTempQueueHoldsMessagesWithConsumers(); 54 | } 55 | 56 | [Test] 57 | public override void TestTempQueueHoldsMessagesWithoutConsumers() 58 | { 59 | base.TestTempQueueHoldsMessagesWithoutConsumers(); 60 | } 61 | 62 | [Test] 63 | public override void TestTmpQueueWorksUnderLoad() 64 | { 65 | base.TestTmpQueueWorksUnderLoad(); 66 | } 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /README.txt: -------------------------------------------------------------------------------- 1 | ======================================================================= 2 | Welcome to: 3 | * Apache.NMS.MSMQ : Apache NMS for MSMQ Client Library 4 | ======================================================================= 5 | 6 | For more information see http://activemq.apache.org/nms 7 | 8 | ======================================================================= 9 | Building With NAnt 0.86 see http://nant.sourceforge.net/ 10 | ======================================================================= 11 | 12 | NAnt version 0.86 or newer is required to build Apache.NMS.MSMQ. Version 0.90 13 | or newer is highly recommended. 14 | To build the code using NAnt, run: 15 | 16 | nant 17 | 18 | To run the unit tests you need to run an Apache ActiveMQ Broker first then run: 19 | 20 | nant test 21 | 22 | The NMS documentation can be generated into three different formats using 23 | Microsoft's Sandcastle open source product. The Sandcastle Styles project 24 | was used to enhance the output generated from the current release of Sandcastle. 25 | 26 | The Sandcastle project is located here: 27 | 28 | http://sandcastle.codeplex.com/ 29 | 30 | The Sandcastle Styles project is located here: 31 | 32 | http://sandcastlestyles.codeplex.com/ 33 | 34 | To generate the documentation, run: 35 | 36 | nant sandcastle-all 37 | 38 | ======================================================================= 39 | Building With Visual Studio 2008 40 | ======================================================================= 41 | 42 | First build the project with nant, this will download and install 43 | all the 3rd party dependencies for you. 44 | 45 | Open the solution File. Build using "Build"->"Build Solution" 46 | menu option. 47 | 48 | The resulting DLLs will be in build\${framework}\debug or the 49 | build\${framework}\release directories depending on your settings 50 | under "Build"->"Configuration Manager" 51 | 52 | If you have the Resharper plugin installed in Visual Studio, you can run 53 | all the Unit Tests by using the "ReSharper"->"Unit Testing"->"Run All 54 | Tests from Solution" menu option. Please note that you must run an 55 | Apache ActiveMQ Broker before kicking off the unit tests. Otherwise, 56 | the standalone NUnit test runner can be used. NUnit version 2.5.8 57 | is required to build and run the unit tests. 58 | 59 | -------------------------------------------------------------------------------- /src/main/csharp/Selector/UnaryExpression.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | using System; 18 | 19 | namespace Apache.NMS.Selector 20 | { 21 | /// 22 | /// An expression which performs an operation on one expression value. 23 | /// 24 | public abstract class UnaryExpression : IExpression 25 | { 26 | protected IExpression rightExpression; 27 | public IExpression Right 28 | { 29 | get { return rightExpression; } 30 | set { rightExpression = value; } 31 | } 32 | 33 | protected abstract string ExpressionSymbol 34 | { 35 | get; 36 | } 37 | 38 | public UnaryExpression(IExpression left) 39 | { 40 | this.rightExpression = left; 41 | } 42 | 43 | public abstract object Evaluate(MessageEvaluationContext message); 44 | 45 | public override string ToString() 46 | { 47 | return "(" + ExpressionSymbol + " " + rightExpression.ToString() + ")"; 48 | } 49 | 50 | public static IExpression CreateNegate(IExpression left) 51 | { 52 | return new NegateExpression(left); 53 | } 54 | 55 | public static IBooleanExpression CreateNOT(IBooleanExpression left) 56 | { 57 | return new NOTExpression(left); 58 | } 59 | 60 | public static IBooleanExpression CreateBooleanCast(IExpression left) 61 | { 62 | return new BooleanCastExpression(left); 63 | } 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /src/test/csharp/NMSTracer.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | #define TRACE // Force tracing to be enabled for this class 19 | 20 | namespace Apache.NMS.Test 21 | { 22 | public class NMSTracer : Apache.NMS.ITrace 23 | { 24 | #region ITrace Members 25 | public void Debug(string message) 26 | { 27 | #if !NETCF 28 | System.Diagnostics.Trace.WriteLine(string.Format("DEBUG: {0}", message)); 29 | #endif 30 | } 31 | 32 | public void Error(string message) 33 | { 34 | #if !NETCF 35 | System.Diagnostics.Trace.WriteLine(string.Format("ERROR: {0}", message)); 36 | #endif 37 | } 38 | 39 | public void Fatal(string message) 40 | { 41 | #if !NETCF 42 | System.Diagnostics.Trace.WriteLine(string.Format("FATAL: {0}", message)); 43 | #endif 44 | } 45 | 46 | public void Info(string message) 47 | { 48 | #if !NETCF 49 | System.Diagnostics.Trace.WriteLine(string.Format("INFO: {0}", message)); 50 | #endif 51 | } 52 | 53 | public void Warn(string message) 54 | { 55 | #if !NETCF 56 | System.Diagnostics.Trace.WriteLine(string.Format("WARN: {0}", message)); 57 | #endif 58 | } 59 | 60 | public bool IsDebugEnabled 61 | { 62 | get { return true; } 63 | } 64 | 65 | public bool IsErrorEnabled 66 | { 67 | get { return true; } 68 | } 69 | 70 | public bool IsFatalEnabled 71 | { 72 | get { return true; } 73 | } 74 | 75 | public bool IsInfoEnabled 76 | { 77 | get { return true; } 78 | } 79 | 80 | public bool IsWarnEnabled 81 | { 82 | get { return true; } 83 | } 84 | 85 | #endregion 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /src/test/csharp/Commands/Topic.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | using System; 18 | 19 | namespace Apache.NMS.Commands 20 | { 21 | 22 | /// 23 | /// Summary description for Topic. 24 | /// 25 | public class Topic : Destination, ITopic 26 | { 27 | public Topic() : base() 28 | { 29 | } 30 | 31 | public Topic(String name) : base(name) 32 | { 33 | } 34 | 35 | override public DestinationType DestinationType 36 | { 37 | get 38 | { 39 | return DestinationType.Topic; 40 | } 41 | } 42 | 43 | public String TopicName 44 | { 45 | get { return PhysicalName; } 46 | } 47 | 48 | public override int GetDestinationType() 49 | { 50 | return TOPIC; 51 | } 52 | 53 | public override Destination CreateDestination(String name) 54 | { 55 | return new Topic(name); 56 | } 57 | 58 | public override Object Clone() 59 | { 60 | // Since we are a derived class use the base's Clone() 61 | // to perform the shallow copy. Since it is shallow it 62 | // will include our derived class. Since we are derived, 63 | // this method is an override. 64 | Topic o = (Topic) base.Clone(); 65 | 66 | // Now do the deep work required 67 | // If any new variables are added then this routine will 68 | // likely need updating 69 | 70 | return o; 71 | } 72 | } 73 | } 74 | 75 | -------------------------------------------------------------------------------- /src/test/csharp/Commands/Queue.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | using System; 18 | 19 | namespace Apache.NMS.Commands 20 | { 21 | /// 22 | /// Summary description for Queue. 23 | /// 24 | public class Queue : Destination, IQueue 25 | { 26 | public Queue() 27 | : base() 28 | { 29 | } 30 | 31 | public Queue(String name) 32 | : base(name) 33 | { 34 | } 35 | 36 | override public DestinationType DestinationType 37 | { 38 | get 39 | { 40 | return DestinationType.Queue; 41 | } 42 | } 43 | 44 | public String QueueName 45 | { 46 | get { return PhysicalName; } 47 | } 48 | 49 | public override int GetDestinationType() 50 | { 51 | return QUEUE; 52 | } 53 | 54 | public override Destination CreateDestination(String name) 55 | { 56 | return new Queue(name); 57 | } 58 | 59 | public override Object Clone() 60 | { 61 | // Since we are a derived class use the base's Clone() 62 | // to perform the shallow copy. Since it is shallow it 63 | // will include our derived class. Since we are derived, 64 | // this method is an override. 65 | Queue o = (Queue) base.Clone(); 66 | 67 | // Now do the deep work required 68 | // If any new variables are added then this routine will 69 | // likely need updating 70 | 71 | return o; 72 | } 73 | } 74 | } 75 | 76 | -------------------------------------------------------------------------------- /src/test/csharp/Commands/TempDestination.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | using System; 19 | 20 | namespace Apache.NMS.Commands 21 | { 22 | public abstract class TempDestination : Destination 23 | { 24 | /// 25 | /// Method CreateDestination 26 | /// 27 | /// An Destination 28 | /// A String 29 | public override Destination CreateDestination(String name) 30 | { 31 | return null; 32 | } 33 | 34 | abstract override public DestinationType DestinationType 35 | { 36 | get; 37 | } 38 | 39 | public TempDestination() 40 | : base() 41 | { 42 | } 43 | 44 | public TempDestination(String name) 45 | : base(name) 46 | { 47 | } 48 | 49 | public override Object Clone() 50 | { 51 | // Since we are a derived class use the base's Clone() 52 | // to perform the shallow copy. Since it is shallow it 53 | // will include our derived class. Since we are derived, 54 | // this method is an override. 55 | TempDestination o = (TempDestination) base.Clone(); 56 | 57 | // Now do the deep work required 58 | // If any new variables are added then this routine will 59 | // likely need updating 60 | 61 | return o; 62 | } 63 | 64 | public void Delete() 65 | { 66 | throw new NotSupportedException("Stomp Cannot Delete Temporary Destinations"); 67 | } 68 | } 69 | } 70 | 71 | -------------------------------------------------------------------------------- /src/test/csharp/Commands/TempTopic.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | using System; 18 | 19 | namespace Apache.NMS.Commands 20 | { 21 | 22 | /// 23 | /// A Temporary Topic 24 | /// 25 | public class TempTopic : TempDestination, ITemporaryTopic 26 | { 27 | public TempTopic() : base() 28 | { 29 | } 30 | 31 | public TempTopic(String name) : base(name) 32 | { 33 | } 34 | 35 | override public DestinationType DestinationType 36 | { 37 | get { return DestinationType.TemporaryTopic; } 38 | } 39 | 40 | public String TopicName 41 | { 42 | get { return PhysicalName; } 43 | } 44 | 45 | public String GetTopicName() 46 | { 47 | return PhysicalName; 48 | } 49 | 50 | public override int GetDestinationType() 51 | { 52 | return TEMPORARY_TOPIC; 53 | } 54 | 55 | public override Destination CreateDestination(String name) 56 | { 57 | return new TempTopic(name); 58 | } 59 | 60 | public override Object Clone() 61 | { 62 | // Since we are a derived class use the base's Clone() 63 | // to perform the shallow copy. Since it is shallow it 64 | // will include our derived class. Since we are derived, 65 | // this method is an override. 66 | TempTopic o = (TempTopic) base.Clone(); 67 | 68 | // Now do the deep work required 69 | // If any new variables are added then this routine will 70 | // likely need updating 71 | 72 | return o; 73 | } 74 | 75 | } 76 | } 77 | 78 | -------------------------------------------------------------------------------- /src/test/csharp/Commands/TempQueue.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | using System; 18 | 19 | namespace Apache.NMS.Commands 20 | { 21 | /// 22 | /// A Temporary Queue 23 | /// 24 | public class TempQueue : TempDestination, ITemporaryQueue 25 | { 26 | public TempQueue() 27 | : base() 28 | { 29 | } 30 | 31 | public TempQueue(String name) 32 | : base(name) 33 | { 34 | } 35 | 36 | override public DestinationType DestinationType 37 | { 38 | get 39 | { 40 | return DestinationType.TemporaryQueue; 41 | } 42 | } 43 | 44 | public String QueueName 45 | { 46 | get { return PhysicalName; } 47 | } 48 | 49 | public String GetQueueName() 50 | { 51 | return PhysicalName; 52 | } 53 | 54 | public override int GetDestinationType() 55 | { 56 | return TEMPORARY_QUEUE; 57 | } 58 | 59 | public override Destination CreateDestination(String name) 60 | { 61 | return new TempQueue(name); 62 | } 63 | 64 | public override Object Clone() 65 | { 66 | // Since we are a derived class use the base's Clone() 67 | // to perform the shallow copy. Since it is shallow it 68 | // will include our derived class. Since we are derived, 69 | // this method is an override. 70 | TempQueue o = (TempQueue) base.Clone(); 71 | 72 | // Now do the deep work required 73 | // If any new variables are added then this routine will 74 | // likely need updating 75 | 76 | return o; 77 | } 78 | 79 | } 80 | } 81 | 82 | -------------------------------------------------------------------------------- /src/test/csharp/MSMQDurableTest.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | using System; 18 | using Apache.NMS.Util; 19 | using Apache.NMS.Test; 20 | using NUnit.Framework; 21 | 22 | namespace Apache.NMS.MSMQ.Test 23 | { 24 | [TestFixture] 25 | [Ignore("Topics are not supported")] 26 | public class MSMQDurableTest : DurableTest 27 | { 28 | protected const string DEFAULT_TEST_QUEUE = "defaultTestQueue"; 29 | protected const string DEFAULT_TEST_TOPIC = "defaultTestTopic"; 30 | protected const string DURABLE_TEST_TOPIC = "durableConsumerTestTopic"; 31 | 32 | public MSMQDurableTest() 33 | : base(new MSMQTestSupport()) 34 | { 35 | } 36 | 37 | [SetUp] 38 | public override void SetUp() 39 | { 40 | base.SetUp(); 41 | } 42 | 43 | [Test] 44 | public void TestSendWhileClosed( 45 | [Values(AcknowledgementMode.AutoAcknowledge, AcknowledgementMode.ClientAcknowledge, 46 | AcknowledgementMode.DupsOkAcknowledge, AcknowledgementMode.Transactional)] 47 | AcknowledgementMode ackMode) 48 | { 49 | base.TestSendWhileClosed(ackMode, DEFAULT_TEST_TOPIC); 50 | } 51 | 52 | [Test] 53 | public void TestDurableConsumerSelectorChange( 54 | [Values(AcknowledgementMode.AutoAcknowledge, AcknowledgementMode.ClientAcknowledge, 55 | AcknowledgementMode.DupsOkAcknowledge, AcknowledgementMode.Transactional)] 56 | AcknowledgementMode ackMode) 57 | { 58 | base.TestDurableConsumerSelectorChange(ackMode, DEFAULT_TEST_TOPIC); 59 | } 60 | 61 | [Test] 62 | public void TestDurableConsumer( 63 | [Values(AcknowledgementMode.AutoAcknowledge, AcknowledgementMode.ClientAcknowledge, 64 | AcknowledgementMode.DupsOkAcknowledge, AcknowledgementMode.Transactional)] 65 | AcknowledgementMode ackMode) 66 | { 67 | string testDurableTopicURI = GetDestinationURI(DURABLE_TEST_TOPIC); 68 | 69 | base.TestDurableConsumer(ackMode, testDurableTopicURI); 70 | } 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /src/test/csharp/RequestResponseTest.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | using System; 18 | using Apache.NMS.Util; 19 | using NUnit.Framework; 20 | 21 | namespace Apache.NMS.Test 22 | { 23 | //[TestFixture] 24 | public class RequestResponseTest : NMSTest 25 | { 26 | protected RequestResponseTest(NMSTestSupport testSupport) 27 | : base(testSupport) 28 | { 29 | } 30 | 31 | //[Test] 32 | //[Category("RequestResponse")] 33 | public virtual void TestRequestResponseMessaging(string testDestRef, string testRespDestRef) 34 | { 35 | using(IConnection connection = CreateConnection()) 36 | { 37 | connection.Start(); 38 | using(ISession session = connection.CreateSession(AcknowledgementMode.AutoAcknowledge)) 39 | { 40 | IDestination destination = GetClearDestinationByNodeReference(session, testDestRef); 41 | IDestination replyTo = GetClearDestinationByNodeReference(session, testRespDestRef); 42 | 43 | using(IMessageConsumer consumer = session.CreateConsumer(destination)) 44 | using(IMessageProducer producer = session.CreateProducer(destination)) 45 | { 46 | IMessage request = session.CreateMessage(); 47 | 48 | request.NMSReplyTo = replyTo; 49 | 50 | producer.Send(request); 51 | 52 | request = consumer.Receive(TimeSpan.FromMilliseconds(3000)); 53 | Assert.IsNotNull(request); 54 | Assert.IsNotNull(request.NMSReplyTo); 55 | 56 | using(IMessageProducer responder = session.CreateProducer(request.NMSReplyTo)) 57 | { 58 | IMessage response = session.CreateTextMessage("RESPONSE"); 59 | responder.Send(response); 60 | } 61 | } 62 | 63 | using(IMessageConsumer consumer = session.CreateConsumer(replyTo)) 64 | { 65 | ITextMessage response = consumer.Receive(TimeSpan.FromMilliseconds(3000)) as ITextMessage; 66 | Assert.IsNotNull(response); 67 | Assert.AreEqual("RESPONSE", response.Text); 68 | } 69 | } 70 | } 71 | } 72 | } 73 | } 74 | 75 | -------------------------------------------------------------------------------- /src/test/csharp/MSMQProducerTest.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | using System; 18 | using Apache.NMS.Test; 19 | using NUnit.Framework; 20 | 21 | namespace Apache.NMS.MSMQ.Test 22 | { 23 | [TestFixture] 24 | public class MSMQProducerTest : ProducerTest 25 | { 26 | protected const string DEFAULT_TEST_QUEUE = "defaultTestQueue"; 27 | protected const string DEFAULT_TEST_TOPIC = "defaultTestTopic"; 28 | protected const string DEFAULT_TEST_TEMP_QUEUE = "defaultTestTempQueue"; 29 | protected const string DEFAULT_TEST_TEMP_TOPIC = "defaultTestTempTopic"; 30 | 31 | protected const string DEFAULT_TEST_QUEUE2 = "defaultTestQueue2"; 32 | protected const string DEFAULT_TEST_TOPIC2 = "defaultTestTopic2"; 33 | protected const string DEFAULT_TEST_TEMP_QUEUE2 = "defaultTestTempQueue2"; 34 | protected const string DEFAULT_TEST_TEMP_TOPIC2 = "defaultTestTempTopic2"; 35 | 36 | public MSMQProducerTest() 37 | : base(new NMSTestSupport()) 38 | { 39 | } 40 | 41 | [Test] 42 | public override void TestProducerSendToNullDestinationWithoutDefault() 43 | { 44 | base.TestProducerSendToNullDestinationWithoutDefault(); 45 | } 46 | 47 | [Test] 48 | public override void TestProducerSendToNullDestinationWithDefault( 49 | [Values(DEFAULT_TEST_QUEUE /*, DEFAULT_TEST_TOPIC, DEFAULT_TEST_TEMP_QUEUE, DEFAULT_TEST_TEMP_TOPIC*/)] 50 | string testDestRef) 51 | { 52 | base.TestProducerSendToNullDestinationWithDefault(testDestRef); 53 | } 54 | 55 | [Test] 56 | public override void TestProducerSendToNonDefaultDestination( 57 | [Values(DEFAULT_TEST_QUEUE /*, DEFAULT_TEST_TOPIC, DEFAULT_TEST_TEMP_QUEUE, DEFAULT_TEST_TEMP_TOPIC*/)] 58 | string unusedTestDestRef, 59 | [Values(DEFAULT_TEST_QUEUE2 /*, DEFAULT_TEST_TOPIC2, DEFAULT_TEST_TEMP_QUEUE2, DEFAULT_TEST_TEMP_TOPIC2*/)] 60 | string usedTestDestRef) 61 | { 62 | base.TestProducerSendToNonDefaultDestination(unusedTestDestRef, usedTestDestRef); 63 | } 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /src/test/csharp/Commands/MapMessage.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | using System; 19 | using System.IO; 20 | using Apache.NMS; 21 | using Apache.NMS.Util; 22 | 23 | namespace Apache.NMS.Commands 24 | { 25 | public class MapMessage : Message, IMapMessage 26 | { 27 | private PrimitiveMap body; 28 | private PrimitiveMapInterceptor typeConverter; 29 | 30 | public MapMessage() : base() 31 | { 32 | } 33 | 34 | public MapMessage(PrimitiveMap body) : base() 35 | { 36 | this.body = body; 37 | this.typeConverter = new PrimitiveMapInterceptor(this, this.body); 38 | } 39 | 40 | public override void ClearBody() 41 | { 42 | this.body = null; 43 | this.typeConverter = null; 44 | base.ClearBody(); 45 | } 46 | 47 | public override bool ReadOnlyBody 48 | { 49 | get { return base.ReadOnlyBody; } 50 | 51 | set 52 | { 53 | if(this.typeConverter != null) 54 | { 55 | this.typeConverter.ReadOnly = true; 56 | } 57 | 58 | base.ReadOnlyBody = value; 59 | } 60 | } 61 | 62 | 63 | public IPrimitiveMap Body 64 | { 65 | get 66 | { 67 | if(this.body == null) 68 | { 69 | this.body = new PrimitiveMap(); 70 | this.typeConverter = new PrimitiveMapInterceptor(this, this.body); 71 | } 72 | 73 | return this.typeConverter; 74 | } 75 | 76 | set 77 | { 78 | this.body = value as PrimitiveMap; 79 | if(value != null) 80 | { 81 | this.typeConverter = new PrimitiveMapInterceptor(this, value); 82 | } 83 | else 84 | { 85 | this.typeConverter = null; 86 | } 87 | } 88 | } 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /src/main/csharp/TextMessage.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | using System; 18 | 19 | 20 | namespace Apache.NMS.MSMQ 21 | { 22 | public class TextMessage : BaseMessage, ITextMessage 23 | { 24 | public const int SIZE_OF_INT = 4; // sizeof(int) - though causes unsafe issues with net 1.1 25 | 26 | private String text; 27 | 28 | public TextMessage() 29 | { 30 | } 31 | 32 | public TextMessage(String text) 33 | { 34 | this.Text = text; 35 | } 36 | 37 | 38 | // Properties 39 | 40 | public string Text 41 | { 42 | get 43 | { 44 | if(text == null) 45 | { 46 | // now lets read the content 47 | byte[] data = this.Content; 48 | if(data != null) 49 | { 50 | // TODO assume that the text is ASCII 51 | char[] chars = new char[data.Length - SIZE_OF_INT]; 52 | for(int i = 0; i < chars.Length; i++) 53 | { 54 | chars[i] = (char) data[i + SIZE_OF_INT]; 55 | } 56 | text = new String(chars); 57 | } 58 | } 59 | return text; 60 | } 61 | 62 | set 63 | { 64 | this.text = value; 65 | byte[] data = null; 66 | if(text != null) 67 | { 68 | // TODO assume that the text is ASCII 69 | 70 | byte[] sizePrefix = System.BitConverter.GetBytes(text.Length); 71 | data = new byte[text.Length + sizePrefix.Length]; //int at the front of it 72 | 73 | // add the size prefix 74 | for(int j = 0; j < sizePrefix.Length; j++) 75 | { 76 | // The bytes need to be encoded in big endian 77 | if(BitConverter.IsLittleEndian) 78 | { 79 | data[j] = sizePrefix[sizePrefix.Length - j - 1]; 80 | } 81 | else 82 | { 83 | data[j] = sizePrefix[j]; 84 | } 85 | } 86 | 87 | // Add the data. 88 | char[] chars = text.ToCharArray(); 89 | for(int i = 0; i < chars.Length; i++) 90 | { 91 | data[i + sizePrefix.Length] = (byte) chars[i]; 92 | } 93 | } 94 | this.Content = data; 95 | 96 | } 97 | } 98 | 99 | } 100 | } 101 | 102 | -------------------------------------------------------------------------------- /package.ps1: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one or more 2 | # contributor license agreements. See the NOTICE file distributed with 3 | # this work for additional information regarding copyright ownership. 4 | # The ASF licenses this file to You under the Apache License, Version 2.0 5 | # (the "License"); you may not use this file except in compliance with 6 | # the License. You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | 16 | $pkgname = "Apache.NMS.MSMQ" 17 | $pkgver = "1.6-SNAPSHOT" 18 | $configurations = "release", "debug" 19 | $frameworks = "net-2.0", "net-3.5", "net-4.0" 20 | 21 | write-progress "Creating package directory." "Initializing..." 22 | if(!(test-path package)) 23 | { 24 | md package 25 | } 26 | 27 | if(test-path build) 28 | { 29 | pushd build 30 | 31 | $pkgdir = "..\package" 32 | 33 | write-progress "Packaging Application files." "Scanning..." 34 | $zipfile = "$pkgdir\$pkgname-$pkgver-bin.zip" 35 | zip -9 -u -j "$zipfile" ..\LICENSE.txt 36 | zip -9 -u -j "$zipfile" ..\NOTICE.txt 37 | foreach($configuration in $configurations) 38 | { 39 | foreach($framework in $frameworks) 40 | { 41 | zip -9 -u "$zipfile" "$framework\$configuration\$pkgname.dll" 42 | zip -9 -u "$zipfile" "$framework\$configuration\$pkgname.xml" 43 | zip -9 -u "$zipfile" "$framework\$configuration\nmsprovider*.config" 44 | zip -9 -u "$zipfile" "$framework\$configuration\$pkgname.Test.dll" 45 | zip -9 -u "$zipfile" "$framework\$configuration\$pkgname.Test.xml" 46 | if($framework -ieq "mono-2.0") 47 | { 48 | zip -9 -u "$zipfile" "$framework\$configuration\$pkgname.dll.mdb" 49 | zip -9 -u "$zipfile" "$framework\$configuration\$pkgname.Test.dll.mdb" 50 | } 51 | else 52 | { 53 | zip -9 -u "$zipfile" "$framework\$configuration\$pkgname.pdb" 54 | zip -9 -u "$zipfile" "$framework\$configuration\$pkgname.Test.pdb" 55 | } 56 | } 57 | } 58 | 59 | popd 60 | } 61 | 62 | write-progress "Packaging Source code files." "Scanning..." 63 | $pkgdir = "package" 64 | $zipfile = "$pkgdir\$pkgname-$pkgver-src.zip" 65 | 66 | zip -9 -u "$zipfile" LICENSE.txt NOTICE.txt nant-common.xml nant.build package.ps1 vs2008-msmq-test.csproj vs2008-msmq.csproj vs2008-msmq.sln 67 | zip -9 -u -r "$zipfile" keyfile src 68 | 69 | write-progress -Completed "Packaging" "Complete." 70 | -------------------------------------------------------------------------------- /src/test/csharp/TempDestinationDeletionTest.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | using System; 18 | using Apache.NMS.Util; 19 | using NUnit.Framework; 20 | 21 | namespace Apache.NMS.Test 22 | { 23 | //[TestFixture] 24 | public class TempDestinationDeletionTest : NMSTest 25 | { 26 | protected TempDestinationDeletionTest(NMSTestSupport testSupport) 27 | : base(testSupport) 28 | { 29 | } 30 | 31 | //[Test] 32 | public virtual void TestTempDestinationDeletion( 33 | //[Values(MsgDeliveryMode.Persistent, MsgDeliveryMode.NonPersistent)] 34 | MsgDeliveryMode deliveryMode, 35 | //[Values(DELETION_TEST_QUEUE, DELETION_TEST_TOPIC, DELETION_TEST_TEMP_QUEUE, DELETION_TEST_TEMP_TOPIC)] 36 | string testDestRef) 37 | { 38 | using(IConnection connection1 = CreateConnection(GetTestClientId())) 39 | { 40 | connection1.Start(); 41 | using(ISession session = connection1.CreateSession(AcknowledgementMode.AutoAcknowledge)) 42 | { 43 | const int MaxNumDestinations = 100; 44 | 45 | for(int index = 1; index <= MaxNumDestinations; index++) 46 | { 47 | IDestination destination = GetClearDestinationByNodeReference(session, testDestRef); 48 | 49 | using(IMessageProducer producer = session.CreateProducer(destination)) 50 | using(IMessageConsumer consumer = session.CreateConsumer(destination)) 51 | { 52 | producer.DeliveryMode = deliveryMode; 53 | 54 | IMessage request = session.CreateTextMessage("Hello World, Just Passing Through!"); 55 | 56 | request.NMSType = "TEMP_MSG"; 57 | producer.Send(request); 58 | IMessage receivedMsg = consumer.Receive(TimeSpan.FromMilliseconds(5000)); 59 | Assert.IsNotNull(receivedMsg); 60 | Assert.AreEqual(receivedMsg.NMSType, "TEMP_MSG"); 61 | 62 | // Ensures that Consumer closes out its subscription 63 | consumer.Close(); 64 | } 65 | 66 | try 67 | { 68 | session.DeleteDestination(destination); 69 | } 70 | catch(NotSupportedException) 71 | { 72 | // Might as well not try this again. 73 | break; 74 | } 75 | } 76 | } 77 | } 78 | } 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /src/test/csharp/TextMessageTest.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | using System; 18 | using Apache.NMS.Util; 19 | using NUnit.Framework; 20 | 21 | namespace Apache.NMS.Test 22 | { 23 | //[TestFixture] 24 | public class TextMessageTest : NMSTest 25 | { 26 | protected TextMessageTest(NMSTestSupport testSupport) 27 | : base(testSupport) 28 | { 29 | } 30 | 31 | //[Test] 32 | public virtual void TestSendReceiveTextMessage( 33 | //[Values(MsgDeliveryMode.Persistent, MsgDeliveryMode.NonPersistent)] 34 | MsgDeliveryMode deliveryMode, string testDestRef) 35 | { 36 | using(IConnection connection = CreateConnection(GetTestClientId())) 37 | { 38 | connection.Start(); 39 | using(ISession session = connection.CreateSession(AcknowledgementMode.AutoAcknowledge)) 40 | { 41 | IDestination destination = GetClearDestinationByNodeReference(session, testDestRef); 42 | using(IMessageConsumer consumer = session.CreateConsumer(destination)) 43 | using(IMessageProducer producer = session.CreateProducer(destination)) 44 | { 45 | producer.DeliveryMode = deliveryMode; 46 | IMessage request = session.CreateTextMessage("Hello World!"); 47 | producer.Send(request); 48 | 49 | IMessage message = consumer.Receive(receiveTimeout); 50 | AssertTextMessageEqual(request, message); 51 | Assert.AreEqual(deliveryMode, message.NMSDeliveryMode, "NMSDeliveryMode does not match"); 52 | } 53 | } 54 | } 55 | } 56 | 57 | /// 58 | /// Assert that two messages are ITextMessages and their text bodies are equal. 59 | /// 60 | /// 61 | /// 62 | protected void AssertTextMessageEqual(IMessage expected, IMessage actual) 63 | { 64 | ITextMessage expectedTextMsg = expected as ITextMessage; 65 | Assert.IsNotNull(expectedTextMsg, "'expected' message not a text message"); 66 | ITextMessage actualTextMsg = actual as ITextMessage; 67 | Assert.IsNotNull(actualTextMsg, "'actual' message not a text message"); 68 | Assert.AreEqual(expectedTextMsg.Text, actualTextMsg.Text, "Text message does not match."); 69 | } 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /src/main/csharp/Selector/Token.cs: -------------------------------------------------------------------------------- 1 | /* Generated By:CSharpCC: Do not edit this line. Token.cs Version 3.0 */ 2 | /// 3 | /// Describes the input token stream. 4 | /// 5 | 6 | public class Token { 7 | 8 | /// 9 | /// Gets an integer that describes the kind of this token. 10 | /// 11 | /// 12 | /// This numbering system is determined by CSharpCCParser, and 13 | /// a table of these numbers is stored in the class . 14 | /// 15 | public int kind; 16 | 17 | /** 18 | * beginLine and beginColumn describe the position of the first character 19 | * of this token; endLine and endColumn describe the position of the 20 | * last character of this token. 21 | */ 22 | public int beginLine, beginColumn, endLine, endColumn; 23 | 24 | /** 25 | * The string image of the token. 26 | */ 27 | public string image; 28 | 29 | /** 30 | * A reference to the next regular (non-special) token from the input 31 | * stream. If this is the last token from the input stream, or if the 32 | * token manager has not read tokens beyond this one, this field is 33 | * set to null. This is true only if this token is also a regular 34 | * token. Otherwise, see below for a description of the contents of 35 | * this field. 36 | */ 37 | public Token next; 38 | 39 | /** 40 | * This field is used to access special tokens that occur prior to this 41 | * token, but after the immediately preceding regular (non-special) token. 42 | * If there are no such special tokens, this field is set to null. 43 | * When there are more than one such special token, this field refers 44 | * to the last of these special tokens, which in turn refers to the next 45 | * previous special token through its specialToken field, and so on 46 | * until the first special token (whose specialToken field is null). 47 | * The next fields of special tokens refer to other special tokens that 48 | * immediately follow it (without an intervening regular token). If there 49 | * is no such token, this field is null. 50 | */ 51 | public Token specialToken; 52 | 53 | /** 54 | * Returns the image. 55 | */ 56 | public override string ToString() { 57 | return image; 58 | } 59 | 60 | /** 61 | * Returns a new Token object, by default. However, if you want, you 62 | * can create and return subclass objects based on the value of ofKind. 63 | * Simply add the cases to the switch for all those special cases. 64 | * For example, if you have a subclass of Token called IDToken that 65 | * you want to create if ofKind is ID, simlpy add something like : 66 | * 67 | * case MyParserConstants.ID : return new IDToken(); 68 | * 69 | * to the following switch statement. Then you can cast matchedToken 70 | * variable to the appropriate type and use it in your lexical actions. 71 | */ 72 | public static Token NewToken(int ofKind) { 73 | switch(ofKind) { 74 | default : return new Token(); 75 | } 76 | } 77 | 78 | } 79 | -------------------------------------------------------------------------------- /src/main/csharp/Selector/MessageEvaluationContext.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | using System; 18 | using Apache.NMS; 19 | 20 | namespace Apache.NMS.Selector 21 | { 22 | /// 23 | /// MessageEvaluationContext is used to cache selection results. 24 | /// 25 | /// A message usually has multiple selectors applied against it. Some selector 26 | /// have a high cost of evaluating against the message. Those selectors may whish 27 | /// to cache evaluation results associated with the message in the 28 | /// MessageEvaluationContext. 29 | /// 30 | public class MessageEvaluationContext 31 | { 32 | private IMessage nmsMessage; 33 | public IMessage Message 34 | { 35 | get { return nmsMessage; } 36 | set { nmsMessage = value; } 37 | } 38 | 39 | public MessageEvaluationContext(IMessage message) 40 | { 41 | nmsMessage = message; 42 | } 43 | 44 | public object GetProperty(string name) 45 | { 46 | if(name.Length > 3 && 47 | string.Compare(name.Substring(0, 3), "JMS", true) == 0) 48 | { 49 | if(string.Compare(name, "JMSCorrelationID", true) == 0) 50 | { 51 | return nmsMessage.NMSCorrelationID; 52 | } 53 | if(string.Compare(name, "JMSMessageID", true) == 0) 54 | { 55 | return nmsMessage.NMSMessageId; 56 | } 57 | if(string.Compare(name, "JMSPriority", true) == 0) 58 | { 59 | return nmsMessage.NMSPriority; 60 | } 61 | if(string.Compare(name, "JMSTimestamp", true) == 0) 62 | { 63 | return nmsMessage.NMSTimestamp; 64 | } 65 | if(string.Compare(name, "JMSType", true) == 0) 66 | { 67 | return nmsMessage.NMSType; 68 | } 69 | if(string.Compare(name, "JMSDeliveryMode", true) == 0) 70 | { 71 | return nmsMessage.NMSDeliveryMode; 72 | } 73 | } 74 | return nmsMessage.Properties[name]; 75 | } 76 | } 77 | } -------------------------------------------------------------------------------- /src/main/csharp/Selector/ModExpression.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | using System; 18 | 19 | namespace Apache.NMS.Selector 20 | { 21 | /// 22 | /// A filter performing a modulo of two expressions. 23 | /// 24 | public class ModExpression : ArithmeticExpression 25 | { 26 | protected override string ExpressionSymbol 27 | { 28 | get { return "%"; } 29 | } 30 | 31 | public ModExpression(IExpression left, IExpression right) 32 | : base(left, right) 33 | { 34 | } 35 | 36 | public override object Evaluate(MessageEvaluationContext message) 37 | { 38 | object lvalue = Left.Evaluate(message); 39 | if(lvalue == null) return null; 40 | 41 | object rvalue = Right.Evaluate(message); 42 | if(rvalue == null) return null; 43 | 44 | AlignedNumericValues values = new AlignedNumericValues(lvalue, rvalue); 45 | 46 | object result = null; 47 | 48 | switch(values.TypeEnum) 49 | { 50 | case AlignedNumericValues.T.SByteType : result = (sbyte )values.Left % (sbyte )values.Right; break; 51 | case AlignedNumericValues.T.ByteType : result = (byte )values.Left % (byte )values.Right; break; 52 | case AlignedNumericValues.T.CharType : result = (char )values.Left % (char )values.Right; break; 53 | case AlignedNumericValues.T.ShortType : result = (short )values.Left % (short )values.Right; break; 54 | case AlignedNumericValues.T.UShortType: result = (ushort)values.Left % (ushort)values.Right; break; 55 | case AlignedNumericValues.T.IntType : result = (int )values.Left % (int )values.Right; break; 56 | case AlignedNumericValues.T.UIntType : result = (uint )values.Left % (uint )values.Right; break; 57 | case AlignedNumericValues.T.LongType : result = (long )values.Left % (long )values.Right; break; 58 | case AlignedNumericValues.T.ULongType : result = (ulong )values.Left % (ulong )values.Right; break; 59 | case AlignedNumericValues.T.FloatType : result = (float )values.Left % (float )values.Right; break; 60 | case AlignedNumericValues.T.DoubleType: result = (double)values.Left % (double)values.Right; break; 61 | } 62 | 63 | return result; 64 | } 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /src/main/csharp/Selector/DivideExpression.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | using System; 18 | 19 | namespace Apache.NMS.Selector 20 | { 21 | /// 22 | /// A filter performing a division of two expressions. 23 | /// 24 | public class DivideExpression : ArithmeticExpression 25 | { 26 | protected override string ExpressionSymbol 27 | { 28 | get { return "/"; } 29 | } 30 | 31 | public DivideExpression(IExpression left, IExpression right) 32 | : base(left, right) 33 | { 34 | } 35 | 36 | public override object Evaluate(MessageEvaluationContext message) 37 | { 38 | object lvalue = Left.Evaluate(message); 39 | if(lvalue == null) return null; 40 | 41 | object rvalue = Right.Evaluate(message); 42 | if(rvalue == null) return null; 43 | 44 | AlignedNumericValues values = new AlignedNumericValues(lvalue, rvalue); 45 | 46 | object result = null; 47 | 48 | switch(values.TypeEnum) 49 | { 50 | case AlignedNumericValues.T.SByteType : result = (sbyte )values.Left / (sbyte )values.Right; break; 51 | case AlignedNumericValues.T.ByteType : result = (byte )values.Left / (byte )values.Right; break; 52 | case AlignedNumericValues.T.CharType : result = (char )values.Left / (char )values.Right; break; 53 | case AlignedNumericValues.T.ShortType : result = (short )values.Left / (short )values.Right; break; 54 | case AlignedNumericValues.T.UShortType: result = (ushort)values.Left / (ushort)values.Right; break; 55 | case AlignedNumericValues.T.IntType : result = (int )values.Left / (int )values.Right; break; 56 | case AlignedNumericValues.T.UIntType : result = (uint )values.Left / (uint )values.Right; break; 57 | case AlignedNumericValues.T.LongType : result = (long )values.Left / (long )values.Right; break; 58 | case AlignedNumericValues.T.ULongType : result = (ulong )values.Left / (ulong )values.Right; break; 59 | case AlignedNumericValues.T.FloatType : result = (float )values.Left / (float )values.Right; break; 60 | case AlignedNumericValues.T.DoubleType: result = (double)values.Left / (double)values.Right; break; 61 | } 62 | 63 | return result; 64 | } 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /src/main/csharp/Selector/MinusExpression.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | using System; 18 | 19 | namespace Apache.NMS.Selector 20 | { 21 | /// 22 | /// A filter performing a substraction of two expressions. 23 | /// 24 | public class MinusExpression : ArithmeticExpression 25 | { 26 | protected override string ExpressionSymbol 27 | { 28 | get { return "-"; } 29 | } 30 | 31 | public MinusExpression(IExpression left, IExpression right) 32 | : base(left, right) 33 | { 34 | } 35 | 36 | public override object Evaluate(MessageEvaluationContext message) 37 | { 38 | object lvalue = Left.Evaluate(message); 39 | if(lvalue == null) return null; 40 | 41 | object rvalue = Right.Evaluate(message); 42 | if(rvalue == null) return null; 43 | 44 | AlignedNumericValues values = new AlignedNumericValues(lvalue, rvalue); 45 | 46 | object result = null; 47 | 48 | switch(values.TypeEnum) 49 | { 50 | case AlignedNumericValues.T.SByteType : result = (sbyte )values.Left - (sbyte )values.Right; break; 51 | case AlignedNumericValues.T.ByteType : result = (byte )values.Left - (byte )values.Right; break; 52 | case AlignedNumericValues.T.CharType : result = (char )values.Left - (char )values.Right; break; 53 | case AlignedNumericValues.T.ShortType : result = (short )values.Left - (short )values.Right; break; 54 | case AlignedNumericValues.T.UShortType: result = (ushort)values.Left - (ushort)values.Right; break; 55 | case AlignedNumericValues.T.IntType : result = (int )values.Left - (int )values.Right; break; 56 | case AlignedNumericValues.T.UIntType : result = (uint )values.Left - (uint )values.Right; break; 57 | case AlignedNumericValues.T.LongType : result = (long )values.Left - (long )values.Right; break; 58 | case AlignedNumericValues.T.ULongType : result = (ulong )values.Left - (ulong )values.Right; break; 59 | case AlignedNumericValues.T.FloatType : result = (float )values.Left - (float )values.Right; break; 60 | case AlignedNumericValues.T.DoubleType: result = (double)values.Left - (double)values.Right; break; 61 | } 62 | 63 | return result; 64 | } 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /src/main/csharp/ConnectionMetaData.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | using System; 19 | using System.Reflection; 20 | 21 | namespace Apache.NMS.MSMQ 22 | { 23 | /// 24 | /// Implements the Connection Meta-Data feature for Apache.NMS.MSMQ 25 | /// 26 | public class ConnectionMetaData : IConnectionMetaData 27 | { 28 | private int nmsMajorVersion; 29 | private int nmsMinorVersion; 30 | 31 | private string nmsProviderName; 32 | private string nmsVersion; 33 | 34 | private int providerMajorVersion; 35 | private int providerMinorVersion; 36 | private string providerVersion; 37 | 38 | private string[] nmsxProperties; 39 | 40 | public ConnectionMetaData() 41 | { 42 | Assembly self = Assembly.GetExecutingAssembly(); 43 | AssemblyName asmName = self.GetName(); 44 | 45 | this.nmsProviderName = asmName.Name; 46 | this.providerMajorVersion = asmName.Version.Major; 47 | this.providerMinorVersion = asmName.Version.Minor; 48 | this.providerVersion = asmName.Version.ToString(); 49 | 50 | this.nmsxProperties = new String[] { }; 51 | 52 | foreach(AssemblyName name in self.GetReferencedAssemblies()) 53 | { 54 | if(0 == string.Compare(name.Name, "Apache.NMS", true)) 55 | { 56 | this.nmsMajorVersion = name.Version.Major; 57 | this.nmsMinorVersion = name.Version.Minor; 58 | this.nmsVersion = name.Version.ToString(); 59 | 60 | return; 61 | } 62 | } 63 | 64 | throw new NMSException("Could not find a reference to the Apache.NMS Assembly."); 65 | } 66 | 67 | public int NMSMajorVersion 68 | { 69 | get { return this.nmsMajorVersion; } 70 | } 71 | 72 | public int NMSMinorVersion 73 | { 74 | get { return this.nmsMinorVersion; } 75 | } 76 | 77 | public string NMSProviderName 78 | { 79 | get { return this.nmsProviderName; } 80 | } 81 | 82 | public string NMSVersion 83 | { 84 | get { return this.nmsVersion; } 85 | } 86 | 87 | public string[] NMSXPropertyNames 88 | { 89 | get { return this.nmsxProperties; } 90 | } 91 | 92 | public int ProviderMajorVersion 93 | { 94 | get { return this.providerMajorVersion; } 95 | } 96 | 97 | public int ProviderMinorVersion 98 | { 99 | get { return this.providerMinorVersion; } 100 | } 101 | 102 | public string ProviderVersion 103 | { 104 | get { return this.providerVersion; } 105 | } 106 | } 107 | } 108 | -------------------------------------------------------------------------------- /src/main/csharp/Selector/MultiplyExpression.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | using System; 18 | 19 | namespace Apache.NMS.Selector 20 | { 21 | /// 22 | /// A filter performing a multiplication of two expressions. 23 | /// 24 | public class MultiplyExpression : ArithmeticExpression 25 | { 26 | protected override string ExpressionSymbol 27 | { 28 | get { return "*"; } 29 | } 30 | 31 | public MultiplyExpression(IExpression left, IExpression right) 32 | : base(left, right) 33 | { 34 | } 35 | 36 | public override object Evaluate(MessageEvaluationContext message) 37 | { 38 | object lvalue = Left.Evaluate(message); 39 | if(lvalue == null) return null; 40 | 41 | object rvalue = Right.Evaluate(message); 42 | if(rvalue == null) return null; 43 | 44 | AlignedNumericValues values = new AlignedNumericValues(lvalue, rvalue); 45 | 46 | object result = null; 47 | 48 | switch(values.TypeEnum) 49 | { 50 | case AlignedNumericValues.T.SByteType : result = (sbyte )values.Left * (sbyte )values.Right; break; 51 | case AlignedNumericValues.T.ByteType : result = (byte )values.Left * (byte )values.Right; break; 52 | case AlignedNumericValues.T.CharType : result = (char )values.Left * (char )values.Right; break; 53 | case AlignedNumericValues.T.ShortType : result = (short )values.Left * (short )values.Right; break; 54 | case AlignedNumericValues.T.UShortType: result = (ushort)values.Left * (ushort)values.Right; break; 55 | case AlignedNumericValues.T.IntType : result = (int )values.Left * (int )values.Right; break; 56 | case AlignedNumericValues.T.UIntType : result = (uint )values.Left * (uint )values.Right; break; 57 | case AlignedNumericValues.T.LongType : result = (long )values.Left * (long )values.Right; break; 58 | case AlignedNumericValues.T.ULongType : result = (ulong )values.Left * (ulong )values.Right; break; 59 | case AlignedNumericValues.T.FloatType : result = (float )values.Left * (float )values.Right; break; 60 | case AlignedNumericValues.T.DoubleType: result = (double)values.Left * (double)values.Right; break; 61 | } 62 | 63 | return result; 64 | } 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /src/main/csharp/Selector/PlusExpression.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | using System; 18 | 19 | namespace Apache.NMS.Selector 20 | { 21 | /// 22 | /// A filter performing an addition of two expressions. 23 | /// 24 | public class PlusExpression : ArithmeticExpression 25 | { 26 | protected override string ExpressionSymbol 27 | { 28 | get { return "+"; } 29 | } 30 | 31 | public PlusExpression(IExpression left, IExpression right) 32 | : base(left, right) 33 | { 34 | } 35 | 36 | public override object Evaluate(MessageEvaluationContext message) 37 | { 38 | object lvalue = Left.Evaluate(message); 39 | if(lvalue == null) return null; 40 | 41 | object rvalue = Right.Evaluate(message); 42 | if(lvalue is string) return (string)lvalue + rvalue; 43 | if(rvalue == null) return null; 44 | 45 | AlignedNumericValues values = new AlignedNumericValues(lvalue, rvalue); 46 | 47 | object result = null; 48 | 49 | switch(values.TypeEnum) 50 | { 51 | case AlignedNumericValues.T.SByteType : result = (sbyte )values.Left + (sbyte )values.Right; break; 52 | case AlignedNumericValues.T.ByteType : result = (byte )values.Left + (byte )values.Right; break; 53 | case AlignedNumericValues.T.CharType : result = (char )values.Left + (char )values.Right; break; 54 | case AlignedNumericValues.T.ShortType : result = (short )values.Left + (short )values.Right; break; 55 | case AlignedNumericValues.T.UShortType: result = (ushort)values.Left + (ushort)values.Right; break; 56 | case AlignedNumericValues.T.IntType : result = (int )values.Left + (int )values.Right; break; 57 | case AlignedNumericValues.T.UIntType : result = (uint )values.Left + (uint )values.Right; break; 58 | case AlignedNumericValues.T.LongType : result = (long )values.Left + (long )values.Right; break; 59 | case AlignedNumericValues.T.ULongType : result = (ulong )values.Left + (ulong )values.Right; break; 60 | case AlignedNumericValues.T.FloatType : result = (float )values.Left + (float )values.Right; break; 61 | case AlignedNumericValues.T.DoubleType: result = (double)values.Left + (double)values.Right; break; 62 | } 63 | 64 | return result; 65 | } 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /src/test/csharp/MSMQForeignMessageTransformationTest.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | using System; 18 | using Apache.NMS.Util; 19 | using Apache.NMS.Test; 20 | using NUnit.Framework; 21 | 22 | namespace Apache.NMS.MSMQ.Test 23 | { 24 | [TestFixture] 25 | public class MSMQForeignMessageTransformationTest : ForeignMessageTransformationTest 26 | { 27 | protected const string DEFAULT_TEST_QUEUE = "defaultTestQueue"; 28 | protected const string DEFAULT_TEST_TOPIC = "defaultTestTopic"; 29 | 30 | public MSMQForeignMessageTransformationTest() 31 | : base(new MSMQTestSupport()) 32 | { 33 | } 34 | 35 | [Test] 36 | public override void TestSendReceiveForeignMessage( 37 | [Values(DEFAULT_TEST_QUEUE /*, DEFAULT_TEST_TOPIC*/)] 38 | string testDestRef, 39 | [Values(MsgDeliveryMode.Persistent, MsgDeliveryMode.NonPersistent)] 40 | MsgDeliveryMode deliveryMode) 41 | { 42 | base.TestSendReceiveForeignMessage(testDestRef, deliveryMode); 43 | } 44 | 45 | [Test] 46 | public override void TestSendReceiveForeignTextMessage( 47 | [Values(DEFAULT_TEST_QUEUE /*, DEFAULT_TEST_TOPIC*/)] 48 | string testDestRef, 49 | [Values(MsgDeliveryMode.Persistent, MsgDeliveryMode.NonPersistent)] 50 | MsgDeliveryMode deliveryMode) 51 | { 52 | base.TestSendReceiveForeignTextMessage(testDestRef, deliveryMode); 53 | } 54 | 55 | [Test] 56 | public override void TestSendReceiveForeignBytesMessage( 57 | [Values(DEFAULT_TEST_QUEUE /*, DEFAULT_TEST_TOPIC*/)] 58 | string testDestRef, 59 | [Values(MsgDeliveryMode.Persistent, MsgDeliveryMode.NonPersistent)] 60 | MsgDeliveryMode deliveryMode) 61 | { 62 | base.TestSendReceiveForeignBytesMessage(testDestRef, deliveryMode); 63 | } 64 | 65 | [Test] 66 | public override void TestSendReceiveForeignMapMessage( 67 | [Values(DEFAULT_TEST_QUEUE /*, DEFAULT_TEST_TOPIC*/)] 68 | string testDestRef, 69 | [Values(MsgDeliveryMode.Persistent, MsgDeliveryMode.NonPersistent)] 70 | MsgDeliveryMode deliveryMode) 71 | { 72 | base.TestSendReceiveForeignMapMessage(testDestRef, deliveryMode); 73 | } 74 | 75 | [Test] 76 | public override void TestSendReceiveForeignStreamMessage( 77 | [Values(DEFAULT_TEST_QUEUE /*, DEFAULT_TEST_TOPIC*/)] 78 | string testDestRef, 79 | [Values(MsgDeliveryMode.Persistent, MsgDeliveryMode.NonPersistent)] 80 | MsgDeliveryMode deliveryMode) 81 | { 82 | base.TestSendReceiveForeignStreamMessage(testDestRef, deliveryMode); 83 | } 84 | } 85 | } 86 | 87 | -------------------------------------------------------------------------------- /src/main/csharp/Selector/InExpression.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | using System; 18 | using System.Text; 19 | using System.Collections; 20 | using System.Collections.Generic; 21 | 22 | namespace Apache.NMS.Selector 23 | { 24 | /// 25 | /// A boolean expression which checks if an expression value is 26 | /// contained in a list of defined values. 27 | /// 28 | public class InExpression : BooleanUnaryExpression 29 | { 30 | private bool notNot; 31 | private ArrayList elements; 32 | private HashSet hashset; 33 | 34 | protected override string ExpressionSymbol 35 | { 36 | get { return notNot ? "IN" : "NOT IN"; } 37 | } 38 | 39 | public InExpression(IExpression right, ArrayList elements, bool notNot) 40 | : base(right) 41 | { 42 | this.notNot = notNot; 43 | 44 | this.elements = elements; 45 | this.hashset = new HashSet(); 46 | 47 | foreach(object element in elements) 48 | { 49 | hashset.Add((string)element); 50 | } 51 | } 52 | 53 | public override object Evaluate(MessageEvaluationContext message) 54 | { 55 | object rvalue = Right.Evaluate(message); 56 | 57 | bool answer = false; 58 | if(rvalue != null && (rvalue is string)) 59 | { 60 | answer = hashset.Contains((string)rvalue); 61 | } 62 | 63 | return notNot ? answer : !answer; 64 | } 65 | 66 | public override string ToString() 67 | { 68 | StringBuilder answer = new StringBuilder(); 69 | answer.Append(Right); 70 | answer.Append(" "); 71 | answer.Append(ExpressionSymbol); 72 | answer.Append(" ("); 73 | 74 | for(int i = 0; i < elements.Count; i++) 75 | { 76 | if(i > 0) answer.Append(", "); 77 | 78 | string s = (string)elements[i]; 79 | 80 | answer.Append('\''); 81 | for(int c = 0; c < s.Length; c++) 82 | { 83 | char ch = s[c]; 84 | if(ch == '\'') 85 | { 86 | answer.Append(ch); 87 | } 88 | answer.Append(ch); 89 | } 90 | answer.Append('\''); 91 | } 92 | 93 | answer.Append(")"); 94 | return answer.ToString(); 95 | } 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /src/test/csharp/NMSPropertyTest.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | using System; 18 | using Apache.NMS.Util; 19 | using NUnit.Framework; 20 | 21 | namespace Apache.NMS.Test 22 | { 23 | //[TestFixture] 24 | public class NMSPropertyTest : NMSTest 25 | { 26 | // standard NMS properties 27 | protected string expectedText = "Hey this works!"; 28 | protected string correlationID = "FooBar"; 29 | protected MsgPriority priority = MsgPriority.Normal; 30 | protected String type = "FooType"; 31 | protected String groupID = "BarGroup"; 32 | protected int groupSeq = 1; 33 | 34 | protected NMSPropertyTest(NMSTestSupport testSupport) 35 | : base (testSupport) 36 | { 37 | } 38 | 39 | //[Test] 40 | public void TestSendReceiveNMSProperties( 41 | //[Values(MsgDeliveryMode.Persistent, MsgDeliveryMode.NonPersistent)] 42 | MsgDeliveryMode deliveryMode, string testDestRef) 43 | { 44 | using(IConnection connection = CreateConnection(GetTestClientId())) 45 | { 46 | connection.Start(); 47 | using(ISession session = connection.CreateSession(AcknowledgementMode.AutoAcknowledge)) 48 | { 49 | IDestination destination = GetClearDestinationByNodeReference(session, testDestRef); 50 | using(IMessageConsumer consumer = session.CreateConsumer(destination)) 51 | using(IMessageProducer producer = session.CreateProducer(destination)) 52 | { 53 | producer.Priority = priority; 54 | producer.DeliveryMode = deliveryMode; 55 | ITextMessage request = session.CreateTextMessage(expectedText); 56 | 57 | // Set the headers 58 | request.NMSCorrelationID = correlationID; 59 | request.NMSType = type; 60 | request.Properties["NMSXGroupID"] = groupID; 61 | request.Properties["NMSXGroupSeq"] = groupSeq; 62 | 63 | producer.Send(request); 64 | 65 | ITextMessage message = consumer.Receive(receiveTimeout) as ITextMessage; 66 | 67 | Assert.IsNotNull(message, "Did not receive an ITextMessage!"); 68 | Assert.AreEqual(expectedText, message.Text, "Message text does not match."); 69 | 70 | // compare standard NMS headers 71 | Assert.AreEqual(correlationID, message.NMSCorrelationID, "NMSCorrelationID does not match"); 72 | Assert.AreEqual(deliveryMode, message.NMSDeliveryMode, "NMSDeliveryMode does not match"); 73 | Assert.AreEqual(priority, message.NMSPriority, "NMSPriority does not match"); 74 | Assert.AreEqual(type, message.NMSType, "NMSType does not match"); 75 | Assert.AreEqual(groupID, message.Properties["NMSXGroupID"], "NMSXGroupID does not match"); 76 | Assert.AreEqual(groupSeq, message.Properties["NMSXGroupSeq"], "NMSXGroupSeq does not match"); 77 | } 78 | } 79 | } 80 | } 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /src/test/csharp/MSMQConnectionTest.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | using System; 18 | using Apache.NMS.Test; 19 | using NUnit.Framework; 20 | 21 | namespace Apache.NMS.MSMQ.Test 22 | { 23 | [TestFixture] 24 | public class MSMQConnectionTest : ConnectionTest 25 | { 26 | protected const string DEFAULT_TEST_QUEUE = "defaultTestQueue"; 27 | protected const string DEFAULT_TEST_TOPIC = "defaultTestTopic"; 28 | 29 | public MSMQConnectionTest() 30 | : base(new MSMQTestSupport()) 31 | { 32 | } 33 | 34 | [SetUp] 35 | public override void SetUp() 36 | { 37 | base.SetUp(); 38 | } 39 | 40 | [TearDown] 41 | public override void TearDown() 42 | { 43 | base.TearDown(); 44 | } 45 | 46 | /// 47 | /// Verify that it is possible to create multiple connections to the broker. 48 | /// There was a bug in the connection factory which set the clientId member which made 49 | /// it impossible to create an additional connection. 50 | /// 51 | [Test] 52 | public override void TestTwoConnections() 53 | { 54 | base.TestTwoConnections(); 55 | } 56 | 57 | [Test] 58 | public void TestCreateAndDisposeWithConsumer( 59 | [Values(true, false)] 60 | bool disposeConsumer) 61 | { 62 | base.TestCreateAndDisposeWithConsumer(disposeConsumer, DEFAULT_TEST_QUEUE); 63 | } 64 | 65 | [Test] 66 | public void TestCreateAndDisposeWithProducer( 67 | [Values(true, false)] 68 | bool disposeProducer) 69 | { 70 | base.TestCreateAndDisposeWithProducer(disposeProducer, DEFAULT_TEST_QUEUE); 71 | } 72 | 73 | [Test] 74 | public void TestStartAfterSend( 75 | [Values(DEFAULT_TEST_QUEUE /*, DEFAULT_TEST_TOPIC*/)] 76 | string testDestRef, 77 | [Values(MsgDeliveryMode.Persistent, MsgDeliveryMode.NonPersistent)] 78 | MsgDeliveryMode deliveryMode) 79 | { 80 | base.TestStartAfterSend(deliveryMode, testDestRef); 81 | } 82 | 83 | /// 84 | /// Tests if the consumer receives the messages that were sent before the 85 | /// connection was started. 86 | /// 87 | [Test] 88 | public override void TestStoppedConsumerHoldsMessagesTillStarted( 89 | [Values(DEFAULT_TEST_QUEUE /*, DEFAULT_TEST_TOPIC*/)] 90 | string testDestRef) 91 | { 92 | base.TestStoppedConsumerHoldsMessagesTillStarted(testDestRef); 93 | } 94 | 95 | /// 96 | /// Tests if the consumer is able to receive messages even when the 97 | /// connecction restarts multiple times. 98 | /// 99 | [Test] 100 | public override void TestMultipleConnectionStops( 101 | [Values(DEFAULT_TEST_QUEUE /*, DEFAULT_TEST_TOPIC*/)] 102 | string testDestRef) 103 | { 104 | base.TestMultipleConnectionStops(testDestRef); 105 | } 106 | } 107 | } 108 | -------------------------------------------------------------------------------- /src/test/csharp/MSMQTest.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | using System; 19 | using System.Messaging; 20 | using NUnit.Framework; 21 | 22 | namespace Apache.NMS.MSMQ 23 | { 24 | /// 25 | /// Use to test and verify MSMQ behaviour. 26 | /// 27 | [TestFixture] 28 | public class MSMQTest 29 | { 30 | String queueName = ".\\Private$\\FOO"; 31 | 32 | [SetUp] 33 | public void SetUp() 34 | { 35 | } 36 | 37 | [TearDown] 38 | public void TearDown() 39 | { 40 | } 41 | 42 | [Test] 43 | public void TestSendAndReceive() 44 | { 45 | // check to make sure the message queue does not exist already 46 | if(!MessageQueue.Exists(queueName)) 47 | { 48 | // create the new message queue and make it transactional 49 | MessageQueue MQ = MessageQueue.Create(queueName, true); 50 | 51 | // set the label name and close the message queue 52 | MQ.Label = "FOO"; 53 | MQ.Close(); 54 | 55 | Console.WriteLine("Created Queue: " + queueName); 56 | //Assert.Fail("Should have thrown an exception!"); 57 | } 58 | else 59 | { 60 | Console.WriteLine("Queue Existed: " + queueName); 61 | } 62 | 63 | if(!MessageQueue.Exists(".\\Private$\\BAR")) 64 | { 65 | // create the new message queue and make it transactional 66 | MessageQueue MQ = MessageQueue.Create(".\\Private$\\BAR", true); 67 | 68 | // set the label name and close the message queue 69 | MQ.Label = "BAR Label"; 70 | MQ.Close(); 71 | } 72 | else 73 | { 74 | Console.WriteLine("Queue Existed: " + queueName); 75 | } 76 | 77 | // create a message queue transaction and start it 78 | MessageQueueTransaction Transaction = new MessageQueueTransaction(); 79 | Transaction.Begin(); 80 | 81 | MessageQueue MQueue = new MessageQueue(queueName); 82 | 83 | Message Msg = new Message("Hello World"); 84 | Msg.ResponseQueue = new MessageQueue(".\\Private$\\BAR"); 85 | Msg.Priority = MessagePriority.Normal; 86 | Msg.UseJournalQueue = true; 87 | Msg.Label = "Test Label"; 88 | 89 | Msg.AcknowledgeType = AcknowledgeTypes.FullReceive; 90 | Msg.AdministrationQueue = Msg.ResponseQueue; 91 | 92 | // send the message 93 | MQueue.Send(Msg, Transaction); 94 | MQueue.Send(Msg, Transaction); 95 | MQueue.Send(Msg, Transaction); 96 | 97 | // commit the transaction 98 | Transaction.Commit(); 99 | 100 | // Read the message. 101 | MQueue.MessageReadPropertyFilter.SetAll(); 102 | 103 | // the target type we have stored in the message body 104 | 105 | ((XmlMessageFormatter) MQueue.Formatter).TargetTypes = new Type[] { typeof(String) }; 106 | 107 | // read the message from the queue, but only wait for 5 sec 108 | Msg = MQueue.Receive(new TimeSpan(0, 0, 5)); 109 | 110 | // read the order from the message body 111 | Console.WriteLine("Received: " + Msg.Body); 112 | 113 | // close the mesage queue 114 | MQueue.Close(); 115 | } 116 | } 117 | } 118 | 119 | 120 | 121 | -------------------------------------------------------------------------------- /src/main/csharp/Destination.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | using System; 18 | namespace Apache.NMS.MSMQ 19 | { 20 | 21 | /// 22 | /// Summary description for Destination. 23 | /// 24 | public abstract class Destination : IDestination 25 | { 26 | 27 | private String path = ""; 28 | 29 | /** 30 | * The Default Constructor 31 | */ 32 | protected Destination() 33 | { 34 | } 35 | 36 | /** 37 | * Construct the Destination with a defined physical name; 38 | * 39 | * @param name 40 | */ 41 | protected Destination(String name) 42 | { 43 | Path = name; 44 | } 45 | 46 | public void Dispose() 47 | { 48 | } 49 | 50 | public String Path 51 | { 52 | get { return this.path; } 53 | set 54 | { 55 | this.path = value; 56 | if(!this.path.Contains("\\")) 57 | { 58 | // Queues must have paths in them. If no path specified, then 59 | // default to local machine. 60 | this.path = ".\\" + this.path; 61 | } 62 | } 63 | } 64 | 65 | 66 | public bool IsTopic 67 | { 68 | get 69 | { 70 | return DestinationType == DestinationType.Topic 71 | || DestinationType == DestinationType.TemporaryTopic; 72 | } 73 | } 74 | 75 | public bool IsQueue 76 | { 77 | get 78 | { 79 | return !IsTopic; 80 | } 81 | } 82 | 83 | 84 | public bool IsTemporary 85 | { 86 | get 87 | { 88 | return DestinationType == DestinationType.TemporaryQueue 89 | || DestinationType == DestinationType.TemporaryTopic; 90 | } 91 | } 92 | 93 | /** 94 | * @return string representation of this instance 95 | */ 96 | public override String ToString() 97 | { 98 | return this.path; 99 | } 100 | 101 | /** 102 | * @return hashCode for this instance 103 | */ 104 | public override int GetHashCode() 105 | { 106 | int answer = 37; 107 | 108 | if(this.path != null) 109 | { 110 | answer = path.GetHashCode(); 111 | } 112 | if(IsTopic) 113 | { 114 | answer ^= 0xfabfab; 115 | } 116 | return answer; 117 | } 118 | 119 | /** 120 | * if the object passed in is equivalent, return true 121 | * 122 | * @param obj the object to compare 123 | * @return true if this instance and obj are equivalent 124 | */ 125 | public override bool Equals(Object obj) 126 | { 127 | bool result = this == obj; 128 | if(!result && obj != null && obj is Destination) 129 | { 130 | Destination other = (Destination) obj; 131 | result = this.DestinationType == other.DestinationType 132 | && this.path.Equals(other.path); 133 | } 134 | return result; 135 | } 136 | 137 | /** 138 | * Factory method to create a child destination if this destination is a composite 139 | * @param name 140 | * @return the created Destination 141 | */ 142 | public abstract Destination CreateDestination(String name); 143 | 144 | 145 | public abstract DestinationType DestinationType 146 | { 147 | get; 148 | } 149 | 150 | } 151 | } 152 | 153 | -------------------------------------------------------------------------------- /src/main/csharp/Readers/MessageReaderUtil.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Messaging; 3 | using System.Globalization; 4 | using System.Text.RegularExpressions; 5 | /* 6 | * Licensed to the Apache Software Foundation (ASF) under one or more 7 | * contributor license agreements. See the NOTICE file distributed with 8 | * this work for additional information regarding copyright ownership. 9 | * The ASF licenses this file to You under the Apache License, Version 2.0 10 | * (the "License"); you may not use this file except in compliance with 11 | * the License. You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | */ 21 | 22 | namespace Apache.NMS.MSMQ.Readers 23 | { 24 | /// 25 | /// Utility routines for creating MSMQ message readers. 26 | /// 27 | public static class MessageReaderUtil 28 | { 29 | private static Regex basicSelectorRegex = 30 | new Regex(@"^\s*" + 31 | @"(NMSMessageId)\s*=\s*'([^']*)'|" + 32 | @"(NMSCorrelationId)\s*=\s*'([^']*)'|" + 33 | @"(LookupId)\s*=\s*([-+]{0,1}\d+)" + 34 | @"\s*$", 35 | RegexOptions.IgnoreCase | RegexOptions.Compiled); 36 | 37 | /// 38 | /// Creates a message reader for the specified message selector. 39 | /// 40 | /// The MSMQ message queue from which 41 | /// messages will be read. 42 | /// A message converter for mapping 43 | /// MSMQ messages to NMS messages. 44 | /// The message selector. 45 | /// A reader for the specified selector. 46 | public static IMessageReader CreateMessageReader( 47 | MessageQueue messageQueue, IMessageConverter messageConverter, 48 | string selector) 49 | { 50 | IMessageReader reader; 51 | 52 | if(string.IsNullOrEmpty(selector)) 53 | { 54 | reader = new NonFilteringMessageReader(messageQueue, 55 | messageConverter); 56 | } 57 | else 58 | { 59 | Match match = basicSelectorRegex.Match(selector); 60 | if(match.Success) 61 | { 62 | if(!string.IsNullOrEmpty(match.Groups[1].Value)) 63 | { 64 | reader = new ByIdMessageReader(messageQueue, 65 | messageConverter, match.Groups[2].Value); 66 | } 67 | else if(!string.IsNullOrEmpty(match.Groups[3].Value)) 68 | { 69 | reader = new ByCorrelationIdMessageReader(messageQueue, 70 | messageConverter, match.Groups[4].Value); 71 | } 72 | else 73 | { 74 | Int64 lookupId = Int64.Parse(match.Groups[6].Value, 75 | CultureInfo.InvariantCulture); 76 | 77 | reader = new ByLookupIdMessageReader(messageQueue, 78 | messageConverter, lookupId); 79 | } 80 | } 81 | else 82 | { 83 | reader = new BySelectorMessageReader(messageQueue, 84 | messageConverter, selector); 85 | } 86 | } 87 | 88 | return reader; 89 | } 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /src/test/csharp/MSMQAsyncConsumeTest.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | using System.Threading; 18 | using Apache.NMS.Test; 19 | using NUnit.Framework; 20 | 21 | namespace Apache.NMS.MSMQ.Test 22 | { 23 | [TestFixture] 24 | public class MSMQAsyncConsumeTest : AsyncConsumeTest 25 | { 26 | protected static string DEFAULT_TEST_QUEUE = "defaultTestQueue"; 27 | 28 | public MSMQAsyncConsumeTest() : 29 | base(new MSMQTestSupport()) 30 | { 31 | } 32 | 33 | [SetUp] 34 | public override void SetUp() 35 | { 36 | base.SetUp(); 37 | } 38 | 39 | [TearDown] 40 | public override void TearDown() 41 | { 42 | base.TearDown(); 43 | } 44 | 45 | [Test] 46 | public void TestAsynchronousConsume( 47 | [Values(MsgDeliveryMode.Persistent, MsgDeliveryMode.NonPersistent)] 48 | MsgDeliveryMode deliveryMode) 49 | { 50 | base.TestAsynchronousConsume(deliveryMode, DEFAULT_TEST_QUEUE); 51 | } 52 | 53 | [Test] 54 | public void TestCreateConsumerAfterSend( 55 | [Values(MsgDeliveryMode.Persistent, MsgDeliveryMode.NonPersistent)] 56 | MsgDeliveryMode deliveryMode) 57 | { 58 | base.TestCreateConsumerAfterSend(deliveryMode, DEFAULT_TEST_QUEUE); 59 | } 60 | 61 | [Test] 62 | public void TestCreateConsumerBeforeSendAddListenerAfterSend( 63 | [Values(MsgDeliveryMode.Persistent, MsgDeliveryMode.NonPersistent)] 64 | MsgDeliveryMode deliveryMode) 65 | { 66 | base.TestCreateConsumerBeforeSendAddListenerAfterSend(deliveryMode, DEFAULT_TEST_QUEUE); 67 | } 68 | 69 | [Test] 70 | public void TestAsynchronousTextMessageConsume( 71 | [Values(MsgDeliveryMode.Persistent, MsgDeliveryMode.NonPersistent)] 72 | MsgDeliveryMode deliveryMode) 73 | { 74 | base.TestAsynchronousTextMessageConsume(deliveryMode, DEFAULT_TEST_QUEUE); 75 | } 76 | 77 | [Test] 78 | [Ignore("Temporary queues are not supported")] 79 | public void TestTemporaryQueueAsynchronousConsume( 80 | [Values(MsgDeliveryMode.Persistent, MsgDeliveryMode.NonPersistent)] 81 | MsgDeliveryMode deliveryMode) 82 | { 83 | using(IConnection connection = CreateConnectionAndStart(GetTestClientId())) 84 | using(ISession syncSession = connection.CreateSession(AcknowledgementMode.AutoAcknowledge)) 85 | using(ISession asyncSession = connection.CreateSession(AcknowledgementMode.AutoAcknowledge)) 86 | using(IDestination destination = GetClearDestinationByNodeReference(syncSession, DEFAULT_TEST_QUEUE)) 87 | using(ITemporaryQueue tempReplyDestination = syncSession.CreateTemporaryQueue()) 88 | using(IMessageConsumer consumer = asyncSession.CreateConsumer(destination)) 89 | using(IMessageConsumer tempConsumer = asyncSession.CreateConsumer(tempReplyDestination)) 90 | using(IMessageProducer producer = syncSession.CreateProducer(destination)) 91 | { 92 | producer.DeliveryMode = deliveryMode; 93 | tempConsumer.Listener += new MessageListener(OnMessage); 94 | consumer.Listener += new MessageListener(OnQueueMessage); 95 | 96 | IMessage request = syncSession.CreateMessage(); 97 | request.NMSCorrelationID = "TemqQueueAsyncConsume"; 98 | request.NMSType = "Test"; 99 | request.NMSReplyTo = tempReplyDestination; 100 | producer.Send(request); 101 | 102 | WaitForMessageToArrive(); 103 | Assert.AreEqual("TempQueueAsyncResponse", receivedMsg.NMSCorrelationID, "Invalid correlation ID."); 104 | } 105 | } 106 | } 107 | } 108 | -------------------------------------------------------------------------------- /src/test/csharp/EndianTest.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | using System.IO; 19 | using Apache.NMS.Util; 20 | using NUnit.Framework; 21 | 22 | namespace Apache.NMS.Test 23 | { 24 | [TestFixture] 25 | public class EndianTest 26 | { 27 | [Test] 28 | public void TestLongEndian() 29 | { 30 | long value = 0x0102030405060708L; 31 | long newValue = EndianSupport.SwitchEndian(value); 32 | Assert.AreEqual(0x0807060504030201L, newValue); 33 | long actual = EndianSupport.SwitchEndian(newValue); 34 | Assert.AreEqual(value, actual); 35 | } 36 | 37 | [Test] 38 | public void TestIntEndian() 39 | { 40 | int value = 0x12345678; 41 | int newValue = EndianSupport.SwitchEndian(value); 42 | Assert.AreEqual(0x78563412, newValue); 43 | int actual = EndianSupport.SwitchEndian(newValue); 44 | Assert.AreEqual(value, actual); 45 | } 46 | 47 | [Test] 48 | public void TestCharEndian() 49 | { 50 | char value = 'J'; 51 | char newValue = EndianSupport.SwitchEndian(value); 52 | char actual = EndianSupport.SwitchEndian(newValue); 53 | Assert.AreEqual(value, actual); 54 | } 55 | 56 | [Test] 57 | public void TestShortEndian() 58 | { 59 | short value = 0x1234; 60 | short newValue = EndianSupport.SwitchEndian(value); 61 | Assert.AreEqual(0x3412, newValue); 62 | short actual = EndianSupport.SwitchEndian(newValue); 63 | Assert.AreEqual(value, actual); 64 | } 65 | 66 | [Test] 67 | public void TestNegativeLongEndian() 68 | { 69 | long value = -0x0102030405060708L; 70 | long newValue = EndianSupport.SwitchEndian(value); 71 | long actual = EndianSupport.SwitchEndian(newValue); 72 | Assert.AreEqual(value, actual); 73 | } 74 | 75 | [Test] 76 | public void TestNegativeIntEndian() 77 | { 78 | int value = -0x12345678; 79 | int newValue = EndianSupport.SwitchEndian(value); 80 | int actual = EndianSupport.SwitchEndian(newValue); 81 | Assert.AreEqual(value, actual); 82 | } 83 | 84 | [Test] 85 | public void TestNegativeShortEndian() 86 | { 87 | short value = -0x1234; 88 | short newValue = EndianSupport.SwitchEndian(value); 89 | short actual = EndianSupport.SwitchEndian(newValue); 90 | Assert.AreEqual(value, actual); 91 | } 92 | 93 | [Test] 94 | public void TestFloatDontNeedEndianSwitch() 95 | { 96 | float value = -1.223F; 97 | 98 | // Convert to int so we can compare to Java version. 99 | MemoryStream ms = new MemoryStream(4); 100 | BinaryWriter bw = new BinaryWriter(ms); 101 | bw.Write(value); 102 | bw.Close(); 103 | ms = new MemoryStream(ms.ToArray()); 104 | BinaryReader br = new BinaryReader(ms); 105 | 106 | // System.out.println(Integer.toString(Float.floatToIntBits(-1.223F), 16)); 107 | Assert.AreEqual(-0x406374bc, br.ReadInt32()); 108 | } 109 | 110 | [Test] 111 | public void TestDoublDontNeedEndianSwitch() 112 | { 113 | double value = -1.223D; 114 | 115 | // Convert to int so we can compare to Java version. 116 | MemoryStream ms = new MemoryStream(4); 117 | BinaryWriter bw = new BinaryWriter(ms); 118 | bw.Write(value); 119 | bw.Close(); 120 | ms = new MemoryStream(ms.ToArray()); 121 | BinaryReader br = new BinaryReader(ms); 122 | long longVersion = br.ReadInt64(); 123 | 124 | // System.out.println(Long.toString(Double.doubleToLongBits(-1.223D), 16)); 125 | Assert.AreEqual(-0x400c6e978d4fdf3b, longVersion); 126 | } 127 | } 128 | } 129 | 130 | 131 | 132 | -------------------------------------------------------------------------------- /src/main/csharp/Readers/IMessageReader.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Messaging; 3 | using Apache.NMS.MSMQ; 4 | /* 5 | * Licensed to the Apache Software Foundation (ASF) under one or more 6 | * contributor license agreements. See the NOTICE file distributed with 7 | * this work for additional information regarding copyright ownership. 8 | * The ASF licenses this file to You under the Apache License, Version 2.0 9 | * (the "License"); you may not use this file except in compliance with 10 | * the License. You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | */ 20 | 21 | namespace Apache.NMS.MSMQ.Readers 22 | { 23 | /// 24 | /// MSMQ message reader. 25 | /// 26 | public interface IMessageReader 27 | { 28 | /// 29 | /// Returns without removing (peeks) the first message in the queue 30 | /// referenced by this MessageQueue matching the selection criteria. 31 | /// The Peek method is synchronous, so it blocks the current thread 32 | /// until a message becomes available. 33 | /// 34 | /// Peeked message. 35 | IMessage Peek(); 36 | 37 | /// 38 | /// Returns without removing (peeks) the first message in the queue 39 | /// referenced by this MessageQueue matching the selection criteria. 40 | /// The Peek method is synchronous, so it blocks the current thread 41 | /// until a message becomes available or the specified time-out occurs. 42 | /// 43 | /// Reception time-out. 44 | /// Peeked message. 45 | IMessage Peek(TimeSpan timeSpan); 46 | 47 | /// 48 | /// Receives the first message available in the queue referenced by 49 | /// the MessageQueue matching the selection criteria. 50 | /// This call is synchronous, and blocks the current thread of execution 51 | /// until a message is available. 52 | /// 53 | /// Received message. 54 | IMessage Receive(); 55 | 56 | /// 57 | /// Receives the first message available in the queue referenced by the 58 | /// MessageQueue matching the selection criteria, and waits until either 59 | /// a message is available in the queue, or the time-out expires. 60 | /// 61 | /// Reception time-out. 62 | /// Received message. 63 | IMessage Receive(TimeSpan timeSpan); 64 | 65 | /// 66 | /// Receives the first message available in the transactional queue 67 | /// referenced by the MessageQueue matching the selection criteria. 68 | /// This call is synchronous, and blocks the current thread of execution 69 | /// until a message is available. 70 | /// 71 | /// Transaction. 72 | /// Received message. 73 | IMessage Receive(MessageQueueTransaction transaction); 74 | 75 | /// 76 | /// Receives the first message available in the transactional queue 77 | /// referenced by the MessageQueue matching the selection criteria, 78 | /// and waits until either a message is available in the queue, or the 79 | /// time-out expires. 80 | /// 81 | /// Reception time-out. 82 | /// Transaction. 83 | /// Received message. 84 | IMessage Receive(TimeSpan timeSpan, MessageQueueTransaction transaction); 85 | 86 | /// 87 | /// Checks if an MSMQ message matches the selection criteria. 88 | /// 89 | /// MSMQ message. 90 | /// true if the message matches the selection criteria. 91 | bool Matches(Message message); 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /src/test/csharp/MSMQTransactionTest.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | using System; 19 | using Apache.NMS.Test; 20 | using NUnit.Framework; 21 | 22 | namespace Apache.NMS.MSMQ.Test 23 | { 24 | [TestFixture] 25 | public class MSMQTransactionTest : TransactionTest 26 | { 27 | protected static string TRANSACTION_TEST_QUEUE = "transactionTestQueue"; 28 | 29 | public MSMQTransactionTest() 30 | : base(new MSMQTestSupport()) 31 | { 32 | } 33 | 34 | [Test] 35 | public void TestSendRollback( 36 | [Values(MsgDeliveryMode.Persistent, MsgDeliveryMode.NonPersistent)] 37 | MsgDeliveryMode deliveryMode) 38 | { 39 | base.TestSendRollback(deliveryMode, TRANSACTION_TEST_QUEUE); 40 | } 41 | 42 | [Test] 43 | public void TestSendSessionClose( 44 | [Values(MsgDeliveryMode.Persistent, MsgDeliveryMode.NonPersistent)] 45 | MsgDeliveryMode deliveryMode) 46 | { 47 | base.TestSendSessionClose(deliveryMode, TRANSACTION_TEST_QUEUE); 48 | } 49 | 50 | [Test] 51 | public void TestReceiveRollback( 52 | [Values(MsgDeliveryMode.Persistent, MsgDeliveryMode.NonPersistent)] 53 | MsgDeliveryMode deliveryMode) 54 | { 55 | base.TestReceiveRollback(deliveryMode, TRANSACTION_TEST_QUEUE); 56 | } 57 | 58 | 59 | [Test] 60 | public void TestReceiveTwoThenRollback( 61 | [Values(MsgDeliveryMode.Persistent, MsgDeliveryMode.NonPersistent)] 62 | MsgDeliveryMode deliveryMode) 63 | { 64 | base.TestReceiveTwoThenRollback(deliveryMode, TRANSACTION_TEST_QUEUE); 65 | } 66 | 67 | [Test] 68 | public void TestSendCommitNonTransaction( 69 | [Values(AcknowledgementMode.AutoAcknowledge, AcknowledgementMode.ClientAcknowledge)] 70 | AcknowledgementMode ackMode, 71 | [Values(MsgDeliveryMode.Persistent, MsgDeliveryMode.NonPersistent)] 72 | MsgDeliveryMode deliveryMode) 73 | { 74 | base.TestSendCommitNonTransaction(ackMode, deliveryMode, TRANSACTION_TEST_QUEUE); 75 | } 76 | 77 | [Test] 78 | public void TestReceiveCommitNonTransaction( 79 | [Values(AcknowledgementMode.AutoAcknowledge, AcknowledgementMode.ClientAcknowledge)] 80 | AcknowledgementMode ackMode, 81 | [Values(MsgDeliveryMode.Persistent, MsgDeliveryMode.NonPersistent)] 82 | MsgDeliveryMode deliveryMode) 83 | { 84 | base.TestReceiveCommitNonTransaction(ackMode, deliveryMode, TRANSACTION_TEST_QUEUE); 85 | } 86 | 87 | [Test] 88 | public void TestReceiveRollbackNonTransaction( 89 | [Values(AcknowledgementMode.AutoAcknowledge, AcknowledgementMode.ClientAcknowledge)] 90 | AcknowledgementMode ackMode, 91 | [Values(MsgDeliveryMode.Persistent, MsgDeliveryMode.NonPersistent)] 92 | MsgDeliveryMode deliveryMode) 93 | { 94 | base.TestReceiveRollbackNonTransaction(ackMode, deliveryMode, TRANSACTION_TEST_QUEUE); 95 | } 96 | 97 | [Test] 98 | public void TestRedispatchOfRolledbackTx( 99 | [Values(MsgDeliveryMode.Persistent, MsgDeliveryMode.NonPersistent)] 100 | MsgDeliveryMode deliveryMode) 101 | { 102 | base.TestRedispatchOfRolledbackTx(deliveryMode, TRANSACTION_TEST_QUEUE); 103 | } 104 | 105 | [Test] 106 | public void TestRedispatchOfUncommittedTx( 107 | [Values(MsgDeliveryMode.Persistent, MsgDeliveryMode.NonPersistent)] 108 | MsgDeliveryMode deliveryMode) 109 | { 110 | base.TestRedispatchOfUncommittedTx(deliveryMode, TRANSACTION_TEST_QUEUE); 111 | } 112 | } 113 | } 114 | 115 | 116 | -------------------------------------------------------------------------------- /src/test/csharp/StreamMessageTest.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | using Apache.NMS.Util; 18 | using NUnit.Framework; 19 | 20 | namespace Apache.NMS.Test 21 | { 22 | //[TestFixture] 23 | public class StreamMessageTest : NMSTest 24 | { 25 | protected bool a = true; 26 | protected byte b = 123; 27 | protected char c = 'c'; 28 | protected short d = 0x1234; 29 | protected int e = 0x12345678; 30 | protected long f = 0x1234567812345678; 31 | protected string g = "Hello World!"; 32 | protected bool h = false; 33 | protected byte i = 0xFF; 34 | protected short j = -0x1234; 35 | protected int k = -0x12345678; 36 | protected long l = -0x1234567812345678; 37 | protected float m = 2.1F; 38 | protected double n = 2.3; 39 | 40 | protected StreamMessageTest(NMSTestSupport testSupport) 41 | : base(testSupport) 42 | { 43 | } 44 | 45 | //[Test] 46 | public virtual void TestSendReceiveStreamMessage( 47 | //[Values(MsgDeliveryMode.Persistent, MsgDeliveryMode.NonPersistent)] 48 | MsgDeliveryMode deliveryMode, string testDestRef) 49 | { 50 | using(IConnection connection = CreateConnection(GetTestClientId())) 51 | { 52 | connection.Start(); 53 | using(ISession session = connection.CreateSession(AcknowledgementMode.AutoAcknowledge)) 54 | { 55 | IDestination destination = GetClearDestinationByNodeReference(session, testDestRef); 56 | using(IMessageConsumer consumer = session.CreateConsumer(destination)) 57 | using(IMessageProducer producer = session.CreateProducer(destination)) 58 | { 59 | producer.DeliveryMode = deliveryMode; 60 | IStreamMessage request; 61 | 62 | try 63 | { 64 | request = session.CreateStreamMessage(); 65 | } 66 | catch(System.NotSupportedException) 67 | { 68 | return; 69 | } 70 | 71 | request.WriteBoolean(a); 72 | request.WriteByte(b); 73 | request.WriteChar(c); 74 | request.WriteInt16(d); 75 | request.WriteInt32(e); 76 | request.WriteInt64(f); 77 | request.WriteString(g); 78 | request.WriteBoolean(h); 79 | request.WriteByte(i); 80 | request.WriteInt16(j); 81 | request.WriteInt32(k); 82 | request.WriteInt64(l); 83 | request.WriteSingle(m); 84 | request.WriteDouble(n); 85 | producer.Send(request); 86 | 87 | IStreamMessage message = consumer.Receive(receiveTimeout) as IStreamMessage; 88 | Assert.IsNotNull(message, "No message returned!"); 89 | Assert.AreEqual(deliveryMode, message.NMSDeliveryMode, "NMSDeliveryMode does not match"); 90 | 91 | // use generic API to access entries 92 | Assert.AreEqual(a, message.ReadBoolean(), "Stream Boolean Value: a"); 93 | Assert.AreEqual(b, message.ReadByte(), "Stream Byte Value: b"); 94 | Assert.AreEqual(c, message.ReadChar(), "Stream Char Value: c"); 95 | Assert.AreEqual(d, message.ReadInt16(), "Stream Int16 Value: d"); 96 | Assert.AreEqual(e, message.ReadInt32(), "Stream Int32 Value: e"); 97 | Assert.AreEqual(f, message.ReadInt64(), "Stream Int64 Value: f"); 98 | Assert.AreEqual(g, message.ReadString(), "Stream String Value: g"); 99 | Assert.AreEqual(h, message.ReadBoolean(), "Stream Boolean Value: h"); 100 | Assert.AreEqual(i, message.ReadByte(), "Stream Byte Value: i"); 101 | Assert.AreEqual(j, message.ReadInt16(), "Stream Int16 Value: j"); 102 | Assert.AreEqual(k, message.ReadInt32(), "Stream Int32 Value: k"); 103 | Assert.AreEqual(l, message.ReadInt64(), "Stream Int64 Value: l"); 104 | Assert.AreEqual(m, message.ReadSingle(), "Stream Single Value: m"); 105 | Assert.AreEqual(n, message.ReadDouble(), "Stream Double Value: n"); 106 | } 107 | } 108 | } 109 | } 110 | } 111 | } 112 | -------------------------------------------------------------------------------- /src/test/csharp/ProducerTest.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | using System; 18 | using NUnit.Framework; 19 | 20 | namespace Apache.NMS.Test 21 | { 22 | //[TestFixture] 23 | public class ProducerTest : NMSTest 24 | { 25 | protected ProducerTest(NMSTestSupport testSupport) 26 | : base(testSupport) 27 | { 28 | } 29 | 30 | //[Test] 31 | public virtual void TestProducerSendToNullDestinationWithoutDefault() 32 | { 33 | using(IConnection connection = CreateConnection(GetTestClientId())) 34 | { 35 | connection.Start(); 36 | using(ISession session = connection.CreateSession()) 37 | { 38 | IMessageProducer producer = session.CreateProducer(null); 39 | 40 | try 41 | { 42 | producer.Send(null, session.CreateTextMessage("Message")); 43 | Assert.Fail("Producer should have thrown an NotSupportedException"); 44 | } 45 | catch(NotSupportedException) 46 | { 47 | } 48 | catch(Exception ex) 49 | { 50 | Assert.Fail("Wrong Exception Type Thrown: " + ex.GetType().Name); 51 | } 52 | } 53 | } 54 | } 55 | 56 | //[Test] 57 | public virtual void TestProducerSendToNullDestinationWithDefault(string testDestRef) 58 | { 59 | using(IConnection connection = CreateConnection(GetTestClientId())) 60 | { 61 | connection.Start(); 62 | using(ISession session = connection.CreateSession()) 63 | { 64 | IDestination unusedDest = GetClearDestinationByNodeReference(session, testDestRef); 65 | 66 | IMessageProducer producer = session.CreateProducer(unusedDest); 67 | 68 | try 69 | { 70 | producer.Send(null, session.CreateTextMessage("Message")); 71 | Assert.Fail("Producer should have thrown an InvalidDestinationException"); 72 | } 73 | catch(InvalidDestinationException) 74 | { 75 | } 76 | catch(Exception ex) 77 | { 78 | Assert.Fail("Wrong Exception Type Thrown: " + ex.GetType().Name); 79 | } 80 | } 81 | } 82 | } 83 | 84 | //[Test] 85 | public virtual void TestProducerSendToNonDefaultDestination(string unusedTestDestRef, string usedTestDestRef) 86 | { 87 | using(IConnection connection = CreateConnection(GetTestClientId())) 88 | { 89 | connection.Start(); 90 | using(ISession session = connection.CreateSession()) 91 | { 92 | IDestination unusedDest = GetClearDestinationByNodeReference(session, unusedTestDestRef); 93 | IDestination usedDest = GetClearDestinationByNodeReference(session, usedTestDestRef); 94 | 95 | IMessageProducer producer = session.CreateProducer(unusedDest); 96 | 97 | try 98 | { 99 | producer.Send(usedDest, session.CreateTextMessage("Message")); 100 | Assert.Fail("Producer should have thrown an NotSupportedException"); 101 | } 102 | catch(NotSupportedException) 103 | { 104 | } 105 | catch(Exception ex) 106 | { 107 | Assert.Fail("Wrong Exception Type Thrown: " + ex.GetType().Name); 108 | } 109 | } 110 | } 111 | } 112 | } 113 | } 114 | -------------------------------------------------------------------------------- /src/main/csharp/Selector/LikeExpression.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | using System; 18 | using System.Text; 19 | using System.Text.RegularExpressions; 20 | using System.Globalization; 21 | 22 | namespace Apache.NMS.Selector 23 | { 24 | /// 25 | /// A filter performing a string matching comparison. 26 | /// 27 | public class LikeExpression : BooleanUnaryExpression 28 | { 29 | private bool notNot; 30 | private Regex pattern; 31 | 32 | protected override string ExpressionSymbol 33 | { 34 | get { return notNot ? "LIKE" : "NOT LIKE"; } 35 | } 36 | 37 | public LikeExpression(IExpression left, string like, string escape, bool notNot) 38 | : base(left) 39 | { 40 | this.notNot = notNot; 41 | 42 | bool doEscape = false; 43 | char escapeChar = '%'; 44 | 45 | if(escape != null) 46 | { 47 | if(escape.Length != 1) 48 | { 49 | throw new ApplicationException("The ESCAPE string litteral is invalid. It can only be one character. Litteral used: " + escape); 50 | } 51 | doEscape = true; 52 | escapeChar = escape[0]; 53 | } 54 | 55 | StringBuilder temp = new StringBuilder(); 56 | StringBuilder regexp = new StringBuilder(like.Length * 2); 57 | regexp.Append("^"); // The beginning of the input 58 | for(int c = 0; c < like.Length; c++) 59 | { 60 | char ch = like[c]; 61 | if(doEscape && (ch == escapeChar)) 62 | { 63 | c++; 64 | if(c >= like.Length) 65 | { 66 | // nothing left to escape... 67 | break; 68 | } 69 | temp.Append(like[c]); 70 | } 71 | else if(ch == '%') 72 | { 73 | if(temp.Length > 0) 74 | { 75 | regexp.Append(Regex.Escape(temp.ToString())); 76 | temp.Length = 0; 77 | } 78 | regexp.Append(".*?"); // Do a non-greedy match 79 | } 80 | else if(c == '_') 81 | { 82 | if(temp.Length > 0) 83 | { 84 | regexp.Append(Regex.Escape(temp.ToString())); 85 | temp.Length = 0; 86 | } 87 | regexp.Append("."); // match one 88 | } 89 | else 90 | { 91 | temp.Append(ch); 92 | } 93 | } 94 | if(temp.Length > 0) 95 | { 96 | regexp.Append(Regex.Escape(temp.ToString())); 97 | } 98 | regexp.Append("$"); // The end of the input 99 | 100 | pattern = new Regex(regexp.ToString(), RegexOptions.Singleline | RegexOptions.Compiled); 101 | } 102 | 103 | public override object Evaluate(MessageEvaluationContext message) 104 | { 105 | object rvalue = this.Right.Evaluate(message); 106 | 107 | bool answer = false; 108 | if(rvalue != null) 109 | { 110 | if(rvalue is string) 111 | { 112 | answer = pattern.IsMatch((string)rvalue); 113 | } 114 | else 115 | { 116 | //throw new ApplicationException("LIKE can only operate on string identifiers. LIKE attemped on " + rvalue.GetType().ToString()); 117 | } 118 | } 119 | 120 | return notNot ? answer : !answer; 121 | } 122 | } 123 | } 124 | -------------------------------------------------------------------------------- /src/main/csharp/QueueBrowser.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | using System; 18 | using System.Collections; 19 | using System.Messaging; 20 | using Apache.NMS; 21 | using Apache.NMS.Util; 22 | using Apache.NMS.MSMQ.Readers; 23 | 24 | namespace Apache.NMS.MSMQ 25 | { 26 | public class QueueBrowser : Apache.NMS.IQueueBrowser 27 | { 28 | private bool disposed = false; 29 | 30 | private readonly Session session; 31 | private MessageQueue messageQueue; 32 | 33 | private string selector; 34 | 35 | private IMessageReader reader; 36 | 37 | public QueueBrowser(Session session, MessageQueue messageQueue) 38 | : this(session, messageQueue, null) 39 | { 40 | } 41 | 42 | public QueueBrowser(Session session, MessageQueue messageQueue, 43 | string selector) 44 | { 45 | this.session = session; 46 | this.messageQueue = messageQueue; 47 | if(null != this.messageQueue) 48 | { 49 | this.messageQueue.MessageReadPropertyFilter.SetAll(); 50 | } 51 | this.selector = selector; 52 | 53 | reader = MessageReaderUtil.CreateMessageReader( 54 | messageQueue, session.MessageConverter, selector); 55 | } 56 | 57 | ~QueueBrowser() 58 | { 59 | Dispose(false); 60 | } 61 | 62 | #region IDisposable Members 63 | 64 | /// 65 | /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. 66 | /// 67 | public void Dispose() 68 | { 69 | Dispose(true); 70 | GC.SuppressFinalize(this); 71 | } 72 | 73 | protected void Dispose(bool disposing) 74 | { 75 | if(disposed) 76 | { 77 | return; 78 | } 79 | 80 | if(disposing) 81 | { 82 | // Dispose managed code here. 83 | } 84 | 85 | try 86 | { 87 | Close(); 88 | } 89 | catch 90 | { 91 | // Ignore errors. 92 | } 93 | 94 | disposed = true; 95 | } 96 | 97 | #endregion 98 | 99 | public void Close() 100 | { 101 | if(messageQueue != null) 102 | { 103 | messageQueue.Dispose(); 104 | messageQueue = null; 105 | } 106 | } 107 | 108 | public string MessageSelector 109 | { 110 | get { return selector; } 111 | } 112 | 113 | public IQueue Queue 114 | { 115 | get { return new Queue(this.messageQueue.Path); } 116 | } 117 | 118 | internal class Enumerator : IEnumerator, IDisposable 119 | { 120 | private Session session; 121 | private MessageEnumerator innerEnumerator; 122 | private IMessageReader reader; 123 | 124 | public Enumerator(Session session, MessageQueue messageQueue, 125 | IMessageReader reader) 126 | { 127 | this.session = session; 128 | this.innerEnumerator = messageQueue.GetMessageEnumerator2(); 129 | this.reader = reader; 130 | } 131 | 132 | public object Current 133 | { 134 | get 135 | { 136 | return this.session.MessageConverter.ToNmsMessage(this.innerEnumerator.Current); 137 | } 138 | } 139 | 140 | public bool MoveNext() 141 | { 142 | while(this.innerEnumerator.MoveNext()) 143 | { 144 | if(reader.Matches(this.innerEnumerator.Current)) 145 | { 146 | return true; 147 | } 148 | } 149 | return false; 150 | } 151 | 152 | public void Reset() 153 | { 154 | this.innerEnumerator.Reset(); 155 | } 156 | 157 | public void Dispose() 158 | { 159 | if(innerEnumerator != null) 160 | { 161 | innerEnumerator.Close(); 162 | innerEnumerator = null; 163 | } 164 | } 165 | } 166 | 167 | public IEnumerator GetEnumerator() 168 | { 169 | return new Enumerator(this.session, this.messageQueue, this.reader); 170 | } 171 | } 172 | } 173 | -------------------------------------------------------------------------------- /src/main/csharp/Selector/TokenMgrError.cs: -------------------------------------------------------------------------------- 1 | /* Generated By:CSharpCC: Do not edit this line. TokenMgrError.cs Version 3.0 */ 2 | public class TokenMgrError : System.SystemException 3 | { 4 | /* 5 | * Ordinals for various reasons why an Exceptions of this type can be thrown. 6 | */ 7 | 8 | /* 9 | * Lexical error occured. 10 | */ 11 | internal static readonly int LexicalError = 0; 12 | 13 | /* 14 | * An attempt wass made to create a second instance of a static token manager. 15 | */ 16 | internal static readonly int StaticLexerError = 1; 17 | 18 | /* 19 | * Tried to change to an invalid lexical state. 20 | */ 21 | internal static readonly int InvalidLexicalState = 2; 22 | 23 | /* 24 | * Detected (and bailed out of) an infinite loop in the token manager. 25 | */ 26 | internal static readonly int LoopDetected = 3; 27 | 28 | /* 29 | * Indicates the reason why the exception is thrown. It will have 30 | * one of the above 4 values. 31 | */ 32 | int errorCode; 33 | 34 | /* 35 | * Replaces unprintable characters by their espaced (or unicode escaped) 36 | * equivalents in the given string 37 | */ 38 | protected static string AddEscapes(string str) { 39 | System.Text.StringBuilder retval = new System.Text.StringBuilder(); 40 | char ch; 41 | for (int i = 0; i < str.Length; i++) { 42 | switch (str[i]) { 43 | case '\0' : 44 | continue; 45 | case '\b': 46 | retval.Append("\\b"); 47 | continue; 48 | case '\t': 49 | retval.Append("\\t"); 50 | continue; 51 | case '\n': 52 | retval.Append("\\n"); 53 | continue; 54 | case '\f': 55 | retval.Append("\\f"); 56 | continue; 57 | case '\r': 58 | retval.Append("\\r"); 59 | continue; 60 | case '\"': 61 | retval.Append("\\\""); 62 | continue; 63 | case '\'': 64 | retval.Append("\\\'"); 65 | continue; 66 | case '\\': 67 | retval.Append("\\\\"); 68 | continue; 69 | default: 70 | if ((ch = str[i]) < 0x20 || ch > 0x7e) { 71 | string s = "0000" + System.Convert.ToString((int)ch, 16); 72 | retval.Append("\\u" + s.Substring(s.Length - 4, s.Length - (s.Length - 4))); 73 | } else { 74 | retval.Append(ch); 75 | } 76 | continue; 77 | } 78 | } 79 | return retval.ToString(); 80 | } 81 | 82 | /* 83 | * Returns a detailed message for the Exception when it is thrown by the 84 | * token manager to indicate a lexical error. 85 | * Parameters : 86 | * EOFSeen : indicates if EOF caused the lexicl error 87 | * curLexState : lexical state in which this error occured 88 | * errorLine : line number when the error occured 89 | * errorColumn : column number when the error occured 90 | * errorAfter : prefix that was seen before this error occured 91 | * curchar : the offending character 92 | * Note: You can customize the lexical error message by modifying this method. 93 | */ 94 | protected static string GetLexicalError(bool EOFSeen, int lexState, int errorLine, int errorColumn, string errorAfter, char curChar) { 95 | return("Lexical error at line " + 96 | errorLine + ", column " + 97 | errorColumn + ". Encountered: " + 98 | (EOFSeen ? " " : ("\"" + AddEscapes(curChar.ToString()) + "\"") + " (" + (int)curChar + "), ") + 99 | "after : \"" + AddEscapes(errorAfter) + "\""); 100 | } 101 | 102 | /* 103 | * You can also modify the body of this method to customize your error messages. 104 | * For example, cases like LOOP_DETECTED and INVALID_LEXICAL_STATE are not 105 | * of end-users concern, so you can return something like : 106 | * 107 | * "Internal Error : Please file a bug report .... " 108 | * 109 | * from this method for such cases in the release version of your parser. 110 | */ 111 | public override string Message { 112 | get { return base.Message; } 113 | } 114 | 115 | /* 116 | * Constructors of various flavors follow. 117 | */ 118 | 119 | public TokenMgrError() { 120 | } 121 | 122 | public TokenMgrError(string message, int reason) : 123 | base(message) { 124 | errorCode = reason; 125 | } 126 | 127 | public TokenMgrError(bool EOFSeen, int lexState, int errorLine, int errorColumn, string errorAfter, char curChar, int reason) : 128 | this(GetLexicalError(EOFSeen, lexState, errorLine, errorColumn, errorAfter, curChar), reason) { 129 | } 130 | } 131 | -------------------------------------------------------------------------------- /src/test/csharp/MessageTransformerTest.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | using System; 18 | using Apache.NMS.Util; 19 | using NUnit.Framework; 20 | 21 | namespace Apache.NMS.Test 22 | { 23 | //[TestFixture] 24 | public class MessageTransformerTest : NMSTest 25 | { 26 | private string propertyName = "ADDITIONAL-PROPERTY"; 27 | private string propertyValue = "ADDITIONAL-PROPERTY-VALUE"; 28 | 29 | protected MessageTransformerTest(NMSTestSupport testSupport) 30 | : base(testSupport) 31 | { 32 | } 33 | 34 | //[Test] 35 | public virtual void TestProducerTransformer( 36 | //[Values(MsgDeliveryMode.Persistent, MsgDeliveryMode.NonPersistent)] 37 | MsgDeliveryMode deliveryMode) 38 | { 39 | using(IConnection connection = CreateConnection()) 40 | { 41 | connection.Start(); 42 | using(ISession session = connection.CreateSession(AcknowledgementMode.AutoAcknowledge)) 43 | { 44 | IDestination destination = session.CreateTemporaryTopic(); 45 | using(IMessageConsumer consumer = session.CreateConsumer(destination)) 46 | using(IMessageProducer producer = session.CreateProducer(destination)) 47 | { 48 | producer.DeliveryMode = deliveryMode; 49 | producer.ProducerTransformer = DoProducerTransform; 50 | 51 | IMessage message = session.CreateMessage(); 52 | 53 | message.Properties["Test"] = "Value"; 54 | 55 | producer.Send(message); 56 | 57 | message = consumer.Receive(TimeSpan.FromMilliseconds(5000)); 58 | 59 | Assert.IsNotNull(message); 60 | Assert.IsTrue(message.Properties.Count == 2); 61 | 62 | Assert.AreEqual("Value", message.Properties["Test"]); 63 | Assert.AreEqual(propertyValue, message.Properties[propertyName]); 64 | } 65 | } 66 | } 67 | } 68 | 69 | //[Test] 70 | public virtual void TestConsumerTransformer( 71 | //[Values(MsgDeliveryMode.Persistent, MsgDeliveryMode.NonPersistent)] 72 | MsgDeliveryMode deliveryMode) 73 | { 74 | using(IConnection connection = CreateConnection()) 75 | { 76 | connection.Start(); 77 | using(ISession session = connection.CreateSession(AcknowledgementMode.AutoAcknowledge)) 78 | { 79 | IDestination destination = session.CreateTemporaryTopic(); 80 | using(IMessageConsumer consumer = session.CreateConsumer(destination)) 81 | using(IMessageProducer producer = session.CreateProducer(destination)) 82 | { 83 | producer.DeliveryMode = deliveryMode; 84 | 85 | consumer.ConsumerTransformer = DoConsumerTransform; 86 | 87 | IMessage message = session.CreateMessage(); 88 | 89 | message.Properties["Test"] = "Value"; 90 | 91 | producer.Send(message); 92 | 93 | message = consumer.Receive(TimeSpan.FromMilliseconds(5000)); 94 | 95 | Assert.IsNotNull(message); 96 | Assert.IsTrue(message.Properties.Count == 2, "Property Count should be 2"); 97 | 98 | Assert.AreEqual("Value", message.Properties["Test"], "Property 'Value' was incorrect"); 99 | Assert.AreEqual(propertyValue, message.Properties[propertyName], "Property not inserted"); 100 | } 101 | } 102 | } 103 | } 104 | 105 | private IMessage DoProducerTransform(ISession session, IMessageProducer producer, IMessage message) 106 | { 107 | message.Properties[propertyName] = propertyValue; 108 | 109 | return message; 110 | } 111 | 112 | private IMessage DoConsumerTransform(ISession session, IMessageConsumer consumer, IMessage message) 113 | { 114 | IMessage newMessage = session.CreateMessage(); 115 | 116 | MessageTransformation.CopyNMSMessageProperties(message, newMessage); 117 | 118 | newMessage.Properties[propertyName] = propertyValue; 119 | 120 | return newMessage; 121 | } 122 | } 123 | } 124 | 125 | -------------------------------------------------------------------------------- /src/main/csharp/ConnectionFactory.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | using System; 18 | using Apache.NMS.Policies; 19 | 20 | namespace Apache.NMS.MSMQ 21 | { 22 | /// 23 | /// A Factory that can estbalish NMS connections to MSMQ 24 | /// 25 | public class ConnectionFactory : IConnectionFactory 26 | { 27 | public const string DEFAULT_BROKER_URL = "msmq://localhost"; 28 | public const string ENV_BROKER_URL = "MSMQ_BROKER_URL"; 29 | private Uri brokerUri; 30 | private IRedeliveryPolicy redeliveryPolicy = new RedeliveryPolicy(); 31 | 32 | public static string GetDefaultBrokerUrl() 33 | { 34 | string answer = Environment.GetEnvironmentVariable(ENV_BROKER_URL); 35 | if(answer == null) 36 | { 37 | answer = DEFAULT_BROKER_URL; 38 | } 39 | return answer; 40 | } 41 | 42 | public ConnectionFactory() 43 | : this(GetDefaultBrokerUrl()) 44 | { 45 | } 46 | 47 | public ConnectionFactory(string brokerUri) 48 | : this(brokerUri, null) 49 | { 50 | } 51 | 52 | public ConnectionFactory(string brokerUri, string clientID) 53 | : this(new Uri(brokerUri), clientID) 54 | { 55 | } 56 | 57 | public ConnectionFactory(Uri brokerUri) 58 | : this(brokerUri, null) 59 | { 60 | } 61 | 62 | public ConnectionFactory(Uri brokerUri, string clientID) 63 | { 64 | this.brokerUri = brokerUri; 65 | } 66 | 67 | /// 68 | /// Creates a new connection to MSMQ. 69 | /// 70 | public IConnection CreateConnection() 71 | { 72 | return CreateConnection(string.Empty, string.Empty, false); 73 | } 74 | 75 | /// 76 | /// Creates a new connection to MSMQ. 77 | /// 78 | public IConnection CreateConnection(string userName, string password) 79 | { 80 | return CreateConnection(userName, password, false); 81 | } 82 | 83 | /// 84 | /// Creates a new connection to MSMQ. 85 | /// 86 | public IConnection CreateConnection(string userName, string password, bool useLogging) 87 | { 88 | IConnection connection = new Connection(); 89 | 90 | connection.RedeliveryPolicy = this.redeliveryPolicy.Clone() as IRedeliveryPolicy; 91 | connection.ConsumerTransformer = this.consumerTransformer; 92 | connection.ProducerTransformer = this.producerTransformer; 93 | 94 | return connection; 95 | } 96 | 97 | /// 98 | /// Get/or set the broker Uri. 99 | /// 100 | public Uri BrokerUri 101 | { 102 | get { return brokerUri; } 103 | set { brokerUri = value; } 104 | } 105 | 106 | /// 107 | /// Get/or set the redelivery policy that new IConnection objects are 108 | /// assigned upon creation. 109 | /// 110 | public IRedeliveryPolicy RedeliveryPolicy 111 | { 112 | get { return this.redeliveryPolicy; } 113 | set 114 | { 115 | if(value != null) 116 | { 117 | this.redeliveryPolicy = value; 118 | } 119 | } 120 | } 121 | 122 | private ConsumerTransformerDelegate consumerTransformer; 123 | public ConsumerTransformerDelegate ConsumerTransformer 124 | { 125 | get { return this.consumerTransformer; } 126 | set { this.consumerTransformer = value; } 127 | } 128 | 129 | private ProducerTransformerDelegate producerTransformer; 130 | public ProducerTransformerDelegate ProducerTransformer 131 | { 132 | get { return this.producerTransformer; } 133 | set { this.producerTransformer = value; } 134 | } 135 | 136 | } 137 | } 138 | --------------------------------------------------------------------------------