Return-Path: Delivered-To: apmail-activemq-commits-archive@www.apache.org Received: (qmail 65149 invoked from network); 18 Aug 2010 18:00:23 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 18 Aug 2010 18:00:23 -0000 Received: (qmail 53939 invoked by uid 500); 18 Aug 2010 18:00:23 -0000 Delivered-To: apmail-activemq-commits-archive@activemq.apache.org Received: (qmail 53879 invoked by uid 500); 18 Aug 2010 18:00:23 -0000 Mailing-List: contact commits-help@activemq.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@activemq.apache.org Delivered-To: mailing list commits@activemq.apache.org Received: (qmail 53872 invoked by uid 99); 18 Aug 2010 18:00:23 -0000 Received: from Unknown (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 18 Aug 2010 18:00:22 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 18 Aug 2010 18:00:00 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id D31762388A02; Wed, 18 Aug 2010 17:58:41 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r986826 - in /activemq/activemq-dotnet: Apache.NMS.ActiveMQ/trunk/src/main/csharp/ Apache.NMS.ActiveMQ/trunk/src/test/csharp/ Apache.NMS/trunk/src/main/csharp/ Apache.NMS/trunk/src/test/csharp/ Date: Wed, 18 Aug 2010 17:58:41 -0000 To: commits@activemq.apache.org From: jgomes@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20100818175841.D31762388A02@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: jgomes Date: Wed Aug 18 17:58:40 2010 New Revision: 986826 URL: http://svn.apache.org/viewvc?rev=986826&view=rev Log: Change default send timeout value to 0. Ensure that the requestTimeout value is propagated from the connection factory on down through the connection down to the producer. Clean up the unit tests to work with these new defaults. Clean up the bytes message test to ensure that all individual property accessors trigger the correct exception scenarios. Fixes [AMQNET-273]. (See https://issues.apache.org/activemq/browse/AMQNET-273) Modified: activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Connection.cs activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/MessageProducer.cs activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Session.cs activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/MessageConsumerTest.cs activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/MessageProducerTest.cs activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/VirtualTopicTest.cs activemq/activemq-dotnet/Apache.NMS/trunk/src/main/csharp/NMSConstants.cs activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/AsyncConsumeTest.cs activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/BytesMessageTest.cs activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/DurableTest.cs activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/MapMessageTest.cs activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/MessageSelectorTest.cs activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/MessageTest.cs activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/NMSPropertyTest.cs activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/NMSTestSupport.cs activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/StreamMessageTest.cs activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/TextMessage.cs activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/TransactionTest.cs activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/XmlMessageTest.cs Modified: activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Connection.cs URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Connection.cs?rev=986826&r1=986825&r2=986826&view=diff ============================================================================== --- activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Connection.cs (original) +++ activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Connection.cs Wed Aug 18 17:58:40 2010 @@ -50,7 +50,7 @@ namespace Apache.NMS.ActiveMQ private readonly Uri brokerUri; private ITransport transport; private ConnectionInfo info; - private TimeSpan requestTimeout; + private TimeSpan requestTimeout; // from connection factory private BrokerInfo brokerInfo; // from broker private WireFormatInfo brokerWireFormatInfo; // from broker private readonly IList sessions = ArrayList.Synchronized(new ArrayList()); Modified: activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/MessageProducer.cs URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/MessageProducer.cs?rev=986826&r1=986825&r2=986826&view=diff ============================================================================== --- activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/MessageProducer.cs (original) +++ activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/MessageProducer.cs Wed Aug 18 17:58:40 2010 @@ -36,7 +36,7 @@ namespace Apache.NMS.ActiveMQ private int producerSequenceId = 0; private MsgDeliveryMode msgDeliveryMode = NMSConstants.defaultDeliveryMode; - private TimeSpan requestTimeout = NMSConstants.defaultRequestTimeout; + private TimeSpan requestTimeout; private TimeSpan msgTimeToLive = NMSConstants.defaultTimeToLive; private MsgPriority msgPriority = NMSConstants.defaultPriority - 1; private bool disableMessageID = false; Modified: activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Session.cs URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Session.cs?rev=986826&r1=986825&r2=986826&view=diff ============================================================================== --- activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Session.cs (original) +++ activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Session.cs Wed Aug 18 17:58:40 2010 @@ -55,8 +55,8 @@ namespace Apache.NMS.ActiveMQ private bool closed = false; private bool closing = false; private TimeSpan disposeStopTimeout = TimeSpan.FromMilliseconds(30000); - private TimeSpan closeStopTimeout = TimeSpan.FromMilliseconds(-1); - private TimeSpan requestTimeout = Apache.NMS.NMSConstants.defaultRequestTimeout; + private TimeSpan closeStopTimeout = TimeSpan.FromMilliseconds(Timeout.Infinite); + private TimeSpan requestTimeout; private AcknowledgementMode acknowledgementMode; public Session(Connection connection, SessionInfo info, AcknowledgementMode acknowledgementMode, bool dispatchAsync) Modified: activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/MessageConsumerTest.cs URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/MessageConsumerTest.cs?rev=986826&r1=986825&r2=986826&view=diff ============================================================================== --- activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/MessageConsumerTest.cs (original) +++ activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/MessageConsumerTest.cs Wed Aug 18 17:58:40 2010 @@ -70,7 +70,6 @@ namespace Apache.NMS.ActiveMQ.Test using(IMessageConsumer consumer = session.CreateConsumer(destination)) using(IMessageProducer producer = session.CreateProducer(destination)) { - producer.RequestTimeout = receiveTimeout; producer.DeliveryMode = deliveryMode; string msgText = "ExpiredMessage:" + Guid.NewGuid().ToString(); Modified: activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/MessageProducerTest.cs URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/MessageProducerTest.cs?rev=986826&r1=986825&r2=986826&view=diff ============================================================================== --- activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/MessageProducerTest.cs (original) +++ activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/MessageProducerTest.cs Wed Aug 18 17:58:40 2010 @@ -21,38 +21,36 @@ using NUnit.Framework; namespace Apache.NMS.ActiveMQ.Test { - [TestFixture] - public class MessageProducerTest - { - [Test] - public void TestProducerSendWithTimeout() - { - Uri uri = new Uri("mock://localhost:61616?connection.RequestTimeout=100&transport.respondToMessages=false"); - - ConnectionFactory factory = new ConnectionFactory(uri); - using(IConnection connection = factory.CreateConnection()) - { - ISession session = connection.CreateSession(); - IDestination destination = session.GetTopic("Test"); - IMessageProducer producer = session.CreateProducer(destination); - - ITextMessage message = session.CreateTextMessage("Hello World"); - - for(int i = 0; i < 10; ++i) - { - DateTime start = DateTime.Now; - - producer.Send(message); - - DateTime end = DateTime.Now; - - TimeSpan elapsed = end - start; - - // We test for something close since its a bit hard to be exact here - Assert.AreEqual(100.0, elapsed.TotalMilliseconds, 10.0); - } - } - } - } + [TestFixture] + public class MessageProducerTest + { + [Test] + public void TestProducerSendWithTimeout() + { + int timeout = 1500; + Uri uri = new Uri(string.Format("mock://localhost:61616?connection.RequestTimeout={0}&transport.respondToMessages=false", timeout)); + + ConnectionFactory factory = new ConnectionFactory(uri); + using(IConnection connection = factory.CreateConnection()) + using(ISession session = connection.CreateSession()) + { + IDestination destination = session.GetTopic("Test"); + using(IMessageProducer producer = session.CreateProducer(destination)) + { + ITextMessage message = session.CreateTextMessage("Hello World"); + + for(int i = 0; i < 10; ++i) + { + DateTime start = DateTime.Now; + + producer.Send(message); + TimeSpan elapsed = DateTime.Now - start; + // Make sure we timed out. + Assert.GreaterOrEqual((int) elapsed.TotalMilliseconds, timeout, "Did not reach timeout limit."); + } + } + } + } + } } Modified: activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/VirtualTopicTest.cs URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/VirtualTopicTest.cs?rev=986826&r1=986825&r2=986826&view=diff ============================================================================== --- activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/VirtualTopicTest.cs (original) +++ activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/VirtualTopicTest.cs Wed Aug 18 17:58:40 2010 @@ -49,7 +49,6 @@ namespace Apache.NMS.ActiveMQ.Test using(IMessageConsumer consumerB = session.CreateConsumer(session.GetQueue(CONSUMER_B_DESTINATION_NAME))) using(IMessageProducer producer = session.CreateProducer(session.GetTopic(PRODUCER_DESTINATION_NAME))) { - producer.RequestTimeout = receiveTimeout; producer.DeliveryMode = deliveryMode; for(int index = 0; index < totalMsgs; index++) @@ -125,7 +124,6 @@ namespace Apache.NMS.ActiveMQ.Test using(IMessageConsumer consumerB = session.CreateConsumer(session.GetQueue(CONSUMER_B_DESTINATION_NAME))) using(IMessageProducer producer = session.CreateProducer(session.GetTopic(PRODUCER_DESTINATION_NAME))) { - producer.RequestTimeout = receiveTimeout; producer.DeliveryMode = deliveryMode; consumerA.Listener += MessageListenerA; Modified: activemq/activemq-dotnet/Apache.NMS/trunk/src/main/csharp/NMSConstants.cs URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS/trunk/src/main/csharp/NMSConstants.cs?rev=986826&r1=986825&r2=986826&view=diff ============================================================================== --- activemq/activemq-dotnet/Apache.NMS/trunk/src/main/csharp/NMSConstants.cs (original) +++ activemq/activemq-dotnet/Apache.NMS/trunk/src/main/csharp/NMSConstants.cs Wed Aug 18 17:58:40 2010 @@ -16,6 +16,7 @@ */ using System; +using System.Threading; namespace Apache.NMS { @@ -56,7 +57,7 @@ namespace Apache.NMS public const MsgPriority defaultPriority = MsgPriority.Normal; public const MsgDeliveryMode defaultDeliveryMode = MsgDeliveryMode.Persistent; public static readonly TimeSpan defaultTimeToLive = TimeSpan.Zero; - public static readonly TimeSpan defaultRequestTimeout = TimeSpan.FromMilliseconds(System.Threading.Timeout.Infinite); + public static readonly TimeSpan defaultRequestTimeout = TimeSpan.FromMilliseconds(Timeout.Infinite); } } Modified: activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/AsyncConsumeTest.cs URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/AsyncConsumeTest.cs?rev=986826&r1=986825&r2=986826&view=diff ============================================================================== --- activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/AsyncConsumeTest.cs (original) +++ activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/AsyncConsumeTest.cs Wed Aug 18 17:58:40 2010 @@ -62,7 +62,6 @@ namespace Apache.NMS.Test using(IMessageProducer producer = session.CreateProducer(destination)) { producer.DeliveryMode = deliveryMode; - producer.RequestTimeout = receiveTimeout; consumer.Listener += new MessageListener(OnMessage); IMessage request = session.CreateMessage(); @@ -91,7 +90,6 @@ namespace Apache.NMS.Test using(IMessageProducer producer = session.CreateProducer(destination)) { producer.DeliveryMode = deliveryMode; - producer.RequestTimeout = receiveTimeout; IMessage request = session.CreateMessage(); request.NMSCorrelationID = "AsyncConsumeAfterSend"; @@ -124,7 +122,6 @@ namespace Apache.NMS.Test using(IMessageProducer producer = session.CreateProducer(destination)) { producer.DeliveryMode = deliveryMode; - producer.RequestTimeout = receiveTimeout; IMessage request = session.CreateMessage(); request.NMSCorrelationID = "AsyncConsumeAfterSendLateListener"; @@ -157,7 +154,6 @@ namespace Apache.NMS.Test using(IMessageProducer producer = session.CreateProducer(destination)) { producer.DeliveryMode = deliveryMode; - producer.RequestTimeout = receiveTimeout; ITextMessage request = session.CreateTextMessage("Hello, World!"); request.NMSCorrelationID = "AsyncConsumeTextMessage"; @@ -195,7 +191,6 @@ namespace Apache.NMS.Test using(IMessageProducer producer = session.CreateProducer(destination)) { producer.DeliveryMode = deliveryMode; - producer.RequestTimeout = receiveTimeout; tempConsumer.Listener += new MessageListener(OnMessage); consumer.Listener += new MessageListener(OnQueueMessage); @@ -223,7 +218,6 @@ namespace Apache.NMS.Test using(IMessageProducer producer = session.CreateProducer(message.NMSReplyTo)) { producer.DeliveryMode = message.NMSDeliveryMode; - producer.RequestTimeout = receiveTimeout; ITextMessage response = session.CreateTextMessage("Asynchronous Response Message Text"); response.NMSCorrelationID = "TempQueueAsyncResponse"; Modified: activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/BytesMessageTest.cs URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/BytesMessageTest.cs?rev=986826&r1=986825&r2=986826&view=diff ============================================================================== --- activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/BytesMessageTest.cs (original) +++ activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/BytesMessageTest.cs Wed Aug 18 17:58:40 2010 @@ -15,6 +15,7 @@ * limitations under the License. */ +using System; using Apache.NMS.Util; using NUnit.Framework; @@ -42,7 +43,6 @@ namespace Apache.NMS.Test using(IMessageProducer producer = session.CreateProducer(destination)) { producer.DeliveryMode = deliveryMode; - producer.RequestTimeout = receiveTimeout; IMessage request = session.CreateBytesMessage(msgContent); producer.Send(request); @@ -57,7 +57,7 @@ namespace Apache.NMS.Test } [Test] - public void SendReceiveBytesMessageContentTest( + public void SendReceiveBytesMessageContent( [Values(MsgDeliveryMode.Persistent, MsgDeliveryMode.NonPersistent)] MsgDeliveryMode deliveryMode) { @@ -71,7 +71,6 @@ namespace Apache.NMS.Test using(IMessageProducer producer = session.CreateProducer(destination)) { producer.DeliveryMode = deliveryMode; - producer.RequestTimeout = receiveTimeout; IBytesMessage request = session.CreateBytesMessage(); request.WriteBoolean(true); @@ -101,28 +100,22 @@ namespace Apache.NMS.Test protected void AssertMessageIsReadOnly(IMessage message) { - IBytesMessage theMessage = message as IBytesMessage; + Type writeableExceptionType = typeof(MessageNotWriteableException); + IBytesMessage theMessage = message as IBytesMessage; Assert.IsNotNull(theMessage); - try - { - theMessage.WriteBoolean(true); - theMessage.WriteByte((byte) 1); - theMessage.WriteBytes(new byte[1]); - theMessage.WriteBytes(new byte[3], 0, 2); - theMessage.WriteChar('a'); - theMessage.WriteDouble(1.5); - theMessage.WriteSingle((float) 1.5); - theMessage.WriteInt32(1); - theMessage.WriteInt64(1); - theMessage.WriteObject("stringobj"); - theMessage.WriteInt16((short) 1); - theMessage.WriteString("utfstring"); - Assert.Fail("Message should not have been Writable"); - } - catch(MessageNotWriteableException) - { - } - } + Assert.Throws(writeableExceptionType, delegate () { theMessage.WriteBoolean(true); }); + Assert.Throws(writeableExceptionType, delegate () { theMessage.WriteByte((byte) 1); }); + Assert.Throws(writeableExceptionType, delegate () { theMessage.WriteBytes(new byte[1]); }); + Assert.Throws(writeableExceptionType, delegate () { theMessage.WriteBytes(new byte[3], 0, 2); }); + Assert.Throws(writeableExceptionType, delegate () { theMessage.WriteChar('a'); }); + Assert.Throws(writeableExceptionType, delegate () { theMessage.WriteDouble(1.5); }); + Assert.Throws(writeableExceptionType, delegate () { theMessage.WriteSingle((float) 1.5); }); + Assert.Throws(writeableExceptionType, delegate () { theMessage.WriteInt32(1); }); + Assert.Throws(writeableExceptionType, delegate () { theMessage.WriteInt64(1); }); + Assert.Throws(writeableExceptionType, delegate () { theMessage.WriteObject("stringobj"); }); + Assert.Throws(writeableExceptionType, delegate () { theMessage.WriteInt16((short) 1); }); + Assert.Throws(writeableExceptionType, delegate () { theMessage.WriteString("utfstring"); }); + } /// /// Assert that two messages are IBytesMessages and their contents are equal. Modified: activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/DurableTest.cs URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/DurableTest.cs?rev=986826&r1=986825&r2=986826&view=diff ============================================================================== --- activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/DurableTest.cs (original) +++ activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/DurableTest.cs Wed Aug 18 17:58:40 2010 @@ -233,7 +233,6 @@ namespace Apache.NMS.Test ITextMessage message = session.CreateTextMessage("Durable Hello"); producer.DeliveryMode = MsgDeliveryMode.Persistent; - producer.RequestTimeout = receiveTimeout; producer.Send(message); } } Modified: activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/MapMessageTest.cs URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/MapMessageTest.cs?rev=986826&r1=986825&r2=986826&view=diff ============================================================================== --- activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/MapMessageTest.cs (original) +++ activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/MapMessageTest.cs Wed Aug 18 17:58:40 2010 @@ -59,7 +59,6 @@ namespace Apache.NMS.Test using(IMessageProducer producer = session.CreateProducer(destination)) { producer.DeliveryMode = deliveryMode; - producer.RequestTimeout = receiveTimeout; IMapMessage request = session.CreateMapMessage(); request.Body["a"] = a; request.Body["b"] = b; @@ -137,7 +136,6 @@ namespace Apache.NMS.Test using(IMessageProducer producer = session.CreateProducer(destination)) { producer.DeliveryMode = deliveryMode; - producer.RequestTimeout = receiveTimeout; IMapMessage request = session.CreateMapMessage(); const string textFieldValue = "Nested Map Messages Rule!"; Modified: activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/MessageSelectorTest.cs URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/MessageSelectorTest.cs?rev=986826&r1=986825&r2=986826&view=diff ============================================================================== --- activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/MessageSelectorTest.cs (original) +++ activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/MessageSelectorTest.cs Wed Aug 18 17:58:40 2010 @@ -23,7 +23,6 @@ using NUnit.Framework; namespace Apache.NMS.Test { [TestFixture] - [Explicit] public class MessageSelectorTest : NMSTestSupport { protected const string QUEUE_DESTINATION_NAME = "queue://MessageSelectorQueue"; @@ -37,11 +36,12 @@ namespace Apache.NMS.Test [Test] public void FilterIgnoredMessagesTest( - [Values(MsgDeliveryMode.Persistent, MsgDeliveryMode.NonPersistent)] - MsgDeliveryMode deliveryMode, [Values(QUEUE_DESTINATION_NAME, TOPIC_DESTINATION_NAME)] string destinationName) { + TimeSpan ttl = TimeSpan.FromMinutes(30); + const int MaxNumRequests = 100000; + using(IConnection connection1 = CreateConnection(TEST_CLIENT_ID)) using(IConnection connection2 = CreateConnection(TEST_CLIENT_ID2)) using(IConnection connection3 = CreateConnection(TEST_CLIENT_ID3)) @@ -55,16 +55,15 @@ namespace Apache.NMS.Test { IDestination destination1 = CreateDestination(session1, destinationName); IDestination destination2 = SessionUtil.GetDestination(session2, destinationName); + IDestination destination3 = SessionUtil.GetDestination(session3, destinationName); //jdg + "?consumer.prefetchSize=10000"); using(IMessageProducer producer = session1.CreateProducer(destination1)) using(IMessageConsumer consumer1 = session2.CreateConsumer(destination2, "JMSType NOT LIKE '%IGNORE'")) { - const int MaxNumRequests = 100000; int numNonIgnoredMsgsSent = 0; int numIgnoredMsgsSent = 0; - producer.DeliveryMode = deliveryMode; - // producer.RequestTimeout = receiveTimeout; + producer.DeliveryMode = MsgDeliveryMode.NonPersistent; receivedNonIgnoredMsgCount = 0; receivedIgnoredMsgCount = 0; @@ -75,7 +74,7 @@ namespace Apache.NMS.Test { IMessage request = session1.CreateTextMessage(String.Format("Hello World! [{0} of {1}]", index, MaxNumRequests)); - // request.NMSTimeToLive = TimeSpan.FromSeconds(10); + request.NMSTimeToLive = ttl; if(0 == (index % 2)) { request.NMSType = "ACTIVE"; @@ -92,7 +91,14 @@ namespace Apache.NMS.Test if(20000 == index) { // Start the second consumer - consumer2 = session3.CreateConsumer(destination2, "JMSType LIKE '%IGNORE'"); + if(destination3.IsTopic) + { + // Reset the ignored message sent count, since all previous messages + // will not have been consumed on a topic. + numIgnoredMsgsSent = 0; + } + + consumer2 = session3.CreateConsumer(destination3, "JMSType LIKE '%IGNORE'"); consumer2.Listener += new MessageListener(OnIgnoredMessage); } } @@ -109,23 +115,19 @@ namespace Apache.NMS.Test { // Reset the wait count. waitCount = 0; - Console.WriteLine("Reset the wait count while we are still receiving msgs."); - Thread.Sleep(2000); - continue; + } + else + { + waitCount++; } lastReceivedINongnoredMsgCount = receivedNonIgnoredMsgCount; lastReceivedIgnoredMsgCount = receivedIgnoredMsgCount; - if(waitCount > 60) - { - Assert.Fail(String.Format("Timeout waiting for all messages to be delivered. Only {0} of {1} non-ignored messages delivered. Only {2} of {3} ignored messages delivered.", - receivedNonIgnoredMsgCount, numNonIgnoredMsgsSent, receivedIgnoredMsgCount, numIgnoredMsgsSent)); - } - - Console.WriteLine("Waiting to receive all non-ignored messages..."); + Assert.IsTrue(waitCount <= 30, String.Format("Timeout waiting for all messages to be delivered. Only {0} of {1} non-ignored messages delivered. Only {2} of {3} ignored messages delivered.", + receivedNonIgnoredMsgCount, numNonIgnoredMsgsSent, receivedIgnoredMsgCount, numIgnoredMsgsSent)); + Console.WriteLine("Waiting ({0}) to receive all non-ignored messages...", waitCount); Thread.Sleep(1000); - waitCount++; } consumer2.Dispose(); @@ -144,7 +146,8 @@ namespace Apache.NMS.Test { receivedIgnoredMsgCount++; Assert.AreEqual(message.NMSType, "ACTIVE.IGNORE"); - Thread.Sleep(100); + // Simulate a slow consumer + //Thread.Sleep(10); } } } Modified: activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/MessageTest.cs URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/MessageTest.cs?rev=986826&r1=986825&r2=986826&view=diff ============================================================================== --- activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/MessageTest.cs (original) +++ activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/MessageTest.cs Wed Aug 18 17:58:40 2010 @@ -57,7 +57,6 @@ namespace Apache.NMS.Test using(IMessageProducer producer = session.CreateProducer(destination)) { producer.DeliveryMode = deliveryMode; - producer.RequestTimeout = receiveTimeout; IMessage request = session.CreateMessage(); request.Properties["a"] = a; request.Properties["b"] = b; Modified: activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/NMSPropertyTest.cs URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/NMSPropertyTest.cs?rev=986826&r1=986825&r2=986826&view=diff ============================================================================== --- activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/NMSPropertyTest.cs (original) +++ activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/NMSPropertyTest.cs Wed Aug 18 17:58:40 2010 @@ -51,7 +51,6 @@ namespace Apache.NMS.Test { producer.Priority = priority; producer.DeliveryMode = deliveryMode; - producer.RequestTimeout = receiveTimeout; ITextMessage request = session.CreateTextMessage(expectedText); ITemporaryQueue replyTo = session.CreateTemporaryQueue(); Modified: activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/NMSTestSupport.cs URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/NMSTestSupport.cs?rev=986826&r1=986825&r2=986826&view=diff ============================================================================== --- activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/NMSTestSupport.cs (original) +++ activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/NMSTestSupport.cs Wed Aug 18 17:58:40 2010 @@ -363,7 +363,6 @@ namespace Apache.NMS.Test { IConnection newConnection = Factory.CreateConnection(userName, passWord); Assert.IsNotNull(newConnection, "connection not created"); - newConnection.RequestTimeout = this.receiveTimeout; if(newClientId != null) { newConnection.ClientId = newClientId; Modified: activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/StreamMessageTest.cs URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/StreamMessageTest.cs?rev=986826&r1=986825&r2=986826&view=diff ============================================================================== --- activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/StreamMessageTest.cs (original) +++ activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/StreamMessageTest.cs Wed Aug 18 17:58:40 2010 @@ -56,7 +56,6 @@ namespace Apache.NMS.Test using(IMessageProducer producer = session.CreateProducer(destination)) { producer.DeliveryMode = deliveryMode; - producer.RequestTimeout = receiveTimeout; IStreamMessage request = session.CreateStreamMessage(); request.WriteBoolean(a); request.WriteByte(b); Modified: activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/TextMessage.cs URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/TextMessage.cs?rev=986826&r1=986825&r2=986826&view=diff ============================================================================== --- activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/TextMessage.cs (original) +++ activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/TextMessage.cs Wed Aug 18 17:58:40 2010 @@ -41,7 +41,6 @@ namespace Apache.NMS.Test using(IMessageProducer producer = session.CreateProducer(destination)) { producer.DeliveryMode = deliveryMode; - producer.RequestTimeout = receiveTimeout; IMessage request = session.CreateTextMessage("Hello World!"); producer.Send(request); Modified: activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/TransactionTest.cs URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/TransactionTest.cs?rev=986826&r1=986825&r2=986826&view=diff ============================================================================== --- activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/TransactionTest.cs (original) +++ activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/TransactionTest.cs Wed Aug 18 17:58:40 2010 @@ -43,7 +43,6 @@ namespace Apache.NMS.Test using(IMessageProducer producer = session.CreateProducer(destination)) { producer.DeliveryMode = deliveryMode; - producer.RequestTimeout = receiveTimeout; ITextMessage firstMsgSend = session.CreateTextMessage("First Message"); producer.Send(firstMsgSend); session.Commit(); @@ -99,7 +98,6 @@ namespace Apache.NMS.Test using(IMessageProducer producer = session2.CreateProducer(destination2)) { producer.DeliveryMode = deliveryMode; - producer.RequestTimeout = receiveTimeout; firstMsgSend = session2.CreateTextMessage("First Message"); producer.Send(firstMsgSend); session2.Commit(); @@ -120,7 +118,6 @@ namespace Apache.NMS.Test using(IMessageProducer producer = session2.CreateProducer(destination2)) { producer.DeliveryMode = deliveryMode; - producer.RequestTimeout = receiveTimeout; secondMsgSend = session2.CreateTextMessage("Second Message"); producer.Send(secondMsgSend); session2.Commit(); @@ -157,7 +154,6 @@ namespace Apache.NMS.Test using(IMessageProducer producer = session.CreateProducer(destination)) { producer.DeliveryMode = deliveryMode; - producer.RequestTimeout = receiveTimeout; // Send both messages ITextMessage firstMsgSend = session.CreateTextMessage("First Message"); producer.Send(firstMsgSend); @@ -200,7 +196,6 @@ namespace Apache.NMS.Test using(IMessageProducer producer = session.CreateProducer(destination)) { producer.DeliveryMode = deliveryMode; - producer.RequestTimeout = receiveTimeout; // Send both messages ITextMessage firstMsgSend = session.CreateTextMessage("First Message"); producer.Send(firstMsgSend); @@ -246,7 +241,6 @@ namespace Apache.NMS.Test using(IMessageProducer producer = session.CreateProducer(destination)) { producer.DeliveryMode = deliveryMode; - producer.RequestTimeout = receiveTimeout; ITextMessage firstMsgSend = session.CreateTextMessage("SendCommitNonTransaction Message"); producer.Send(firstMsgSend); try @@ -279,7 +273,6 @@ namespace Apache.NMS.Test using(IMessageProducer producer = session.CreateProducer(destination)) { producer.DeliveryMode = deliveryMode; - producer.RequestTimeout = receiveTimeout; ITextMessage firstMsgSend = session.CreateTextMessage("ReceiveCommitNonTransaction Message"); producer.Send(firstMsgSend); @@ -322,7 +315,6 @@ namespace Apache.NMS.Test using(IMessageProducer producer = session.CreateProducer(destination)) { producer.DeliveryMode = deliveryMode; - producer.RequestTimeout = receiveTimeout; ITextMessage firstMsgSend = session.CreateTextMessage("ReceiveCommitNonTransaction Message"); producer.Send(firstMsgSend); Modified: activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/XmlMessageTest.cs URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/XmlMessageTest.cs?rev=986826&r1=986825&r2=986826&view=diff ============================================================================== --- activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/XmlMessageTest.cs (original) +++ activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/XmlMessageTest.cs Wed Aug 18 17:58:40 2010 @@ -73,7 +73,7 @@ namespace Apache.NMS.Test #if NET_3_5 || MONO [Test] - public void SendReceiveXmlMessage() + public void SendReceiveXmlMessage_Net35() { using(IConnection connection = CreateConnection(TEST_CLIENT_ID)) { @@ -84,8 +84,6 @@ namespace Apache.NMS.Test using(IMessageConsumer consumer = session.CreateConsumer(destination)) using(IMessageProducer producer = session.CreateProducer(destination)) { - producer.RequestTimeout = receiveTimeout; - NMSTestXmlType1 srcIntObject = new NMSTestXmlType1(); srcIntObject.crcCheck = 0xbadf00d; srcIntObject.checkType = CheckType.command; @@ -125,7 +123,8 @@ namespace Apache.NMS.Test } } } -#else +#endif + [Test] public void SendReceiveXmlMessage() { @@ -138,8 +137,6 @@ namespace Apache.NMS.Test using(IMessageConsumer consumer = session.CreateConsumer(destination)) using(IMessageProducer producer = session.CreateProducer(destination)) { - producer.RequestTimeout = receiveTimeout; - NMSTestXmlType1 srcIntObject = new NMSTestXmlType1(); srcIntObject.crcCheck = 0xbadf00d; srcIntObject.checkType = CheckType.command; @@ -179,6 +176,5 @@ namespace Apache.NMS.Test } } } -#endif } }