Return-Path: X-Original-To: apmail-activemq-commits-archive@www.apache.org Delivered-To: apmail-activemq-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 96C559166 for ; Tue, 20 Sep 2011 00:11:27 +0000 (UTC) Received: (qmail 62063 invoked by uid 500); 20 Sep 2011 00:11:27 -0000 Delivered-To: apmail-activemq-commits-archive@activemq.apache.org Received: (qmail 62034 invoked by uid 500); 20 Sep 2011 00:11:27 -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 62027 invoked by uid 99); 20 Sep 2011 00:11:27 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 20 Sep 2011 00:11:27 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.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; Tue, 20 Sep 2011 00:11:24 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id ED00723888FE for ; Tue, 20 Sep 2011 00:11:02 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: svn commit: r1172914 - in /activemq/activemq-dotnet/Apache.NMS.EMS/branches/1.5.x: src/main/csharp/MapMessage.cs src/main/csharp/MessageConsumer.cs src/test/csharp/ReqResponseTempQueue.cs vs2008-ems-test.csproj Date: Tue, 20 Sep 2011 00:11:02 -0000 To: commits@activemq.apache.org From: jgomes@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20110920001102.ED00723888FE@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: jgomes Date: Tue Sep 20 00:11:02 2011 New Revision: 1172914 URL: http://svn.apache.org/viewvc?rev=1172914&view=rev Log: Fix a spurious bug in the close consumer code. The EMS client has a race condition when unregistering a message handler and then closing the consumer. If it happens slowly, then it works correctly. If it happens at full speed, then an exception is thrown. The solution is to not unregister the delegate. Since the consumer is being destroyed anyway, this is a safe thing to (not) do. Updated the MapMessage API to remove calls to obsolete APIs. Added new response temp queue unit test. Added: activemq/activemq-dotnet/Apache.NMS.EMS/branches/1.5.x/src/test/csharp/ReqResponseTempQueue.cs Modified: activemq/activemq-dotnet/Apache.NMS.EMS/branches/1.5.x/src/main/csharp/MapMessage.cs activemq/activemq-dotnet/Apache.NMS.EMS/branches/1.5.x/src/main/csharp/MessageConsumer.cs activemq/activemq-dotnet/Apache.NMS.EMS/branches/1.5.x/vs2008-ems-test.csproj Modified: activemq/activemq-dotnet/Apache.NMS.EMS/branches/1.5.x/src/main/csharp/MapMessage.cs URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.EMS/branches/1.5.x/src/main/csharp/MapMessage.cs?rev=1172914&r1=1172913&r2=1172914&view=diff ============================================================================== --- activemq/activemq-dotnet/Apache.NMS.EMS/branches/1.5.x/src/main/csharp/MapMessage.cs (original) +++ activemq/activemq-dotnet/Apache.NMS.EMS/branches/1.5.x/src/main/csharp/MapMessage.cs Tue Sep 20 00:11:02 2011 @@ -87,16 +87,14 @@ namespace Apache.NMS.EMS get { int count = 0; + try { - IEnumerator namesEnumerator = this.tibcoMapMessage.MapNames; + ICollection mapNames = this.tibcoMapMessage.GetMapNames(); - if(null != namesEnumerator) + if(null != mapNames) { - while(namesEnumerator.MoveNext()) - { - count++; - } + count = mapNames.Count; } } catch(Exception ex) @@ -116,7 +114,7 @@ namespace Apache.NMS.EMS try { - foreach(string itemName in EMSConvert.ToEnumerable(this.tibcoMapMessage.MapNames)) + foreach(string itemName in this.tibcoMapMessage.GetMapNames()) { keys.Add(itemName); } @@ -138,7 +136,7 @@ namespace Apache.NMS.EMS try { - foreach(string itemName in EMSConvert.ToEnumerable(this.tibcoMapMessage.MapNames)) + foreach(string itemName in this.tibcoMapMessage.GetMapNames()) { keys.Add(this.tibcoMapMessage.GetObject(itemName)); } Modified: activemq/activemq-dotnet/Apache.NMS.EMS/branches/1.5.x/src/main/csharp/MessageConsumer.cs URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.EMS/branches/1.5.x/src/main/csharp/MessageConsumer.cs?rev=1172914&r1=1172913&r2=1172914&view=diff ============================================================================== --- activemq/activemq-dotnet/Apache.NMS.EMS/branches/1.5.x/src/main/csharp/MessageConsumer.cs (original) +++ activemq/activemq-dotnet/Apache.NMS.EMS/branches/1.5.x/src/main/csharp/MessageConsumer.cs Tue Sep 20 00:11:02 2011 @@ -108,7 +108,16 @@ namespace Apache.NMS.EMS { if(!this.nmsSession.tibcoSession.IsClosed) { - this.tibcoMessageConsumer.MessageHandler -= this.HandleTibcoMsg; + // JGomes: Calling the following message handler removal code creates an + // instability in the TIBCO consumer and will fail to unregister a consumer. + // This is a very odd bug, but it has been observed that unregistering the + // message handler is not necessary and can be harmful. When the unregister is + // executed slowly step-by-step under a debugger, then it works correctly. When + // it is run full speed, it creates a race condition. Therefore, the code is left + // here in a commented out state to demonstrate what normal cleanup code should + // look like, but don't uncomment it. + + // this.tibcoMessageConsumer.MessageHandler -= this.HandleTibcoMsg; this.tibcoMessageConsumer.Close(); } } Added: activemq/activemq-dotnet/Apache.NMS.EMS/branches/1.5.x/src/test/csharp/ReqResponseTempQueue.cs URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.EMS/branches/1.5.x/src/test/csharp/ReqResponseTempQueue.cs?rev=1172914&view=auto ============================================================================== --- activemq/activemq-dotnet/Apache.NMS.EMS/branches/1.5.x/src/test/csharp/ReqResponseTempQueue.cs (added) +++ activemq/activemq-dotnet/Apache.NMS.EMS/branches/1.5.x/src/test/csharp/ReqResponseTempQueue.cs Tue Sep 20 00:11:02 2011 @@ -0,0 +1,71 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +using System; +using System.Collections; +using NUnit.Framework; + +namespace Apache.NMS.Test +{ + [TestFixture] + public class ReqResponseTempQueueTest : NMSTestSupport + { + [Test] + public void TestTempQueueHoldsMessagesWithConsumers() + { + using(IConnection connection = CreateConnection()) + { + using(ISession session = connection.CreateSession(AcknowledgementMode.AutoAcknowledge)) + { + connection.Start(); + ITemporaryQueue queue = session.CreateTemporaryQueue(); + IMessageProducer producer = session.CreateProducer(queue); + + producer.DeliveryMode = (MsgDeliveryMode.NonPersistent); + + for(int correlationCount = 0; correlationCount < 100; correlationCount++) + { + string correlationId = string.Format("CID_{0}", correlationCount); + IMessageConsumer consumer = null; + + try + { + ITextMessage message = session.CreateTextMessage("Hello"); + + consumer = session.CreateConsumer(queue, string.Format("JMSCorrelationID = '{0}'", correlationId)); + message.NMSCorrelationID = correlationId; + producer.Send(message); + + IMessage message2 = consumer.Receive(TimeSpan.FromMilliseconds(1000)); + Assert.IsNotNull(message2); + Assert.AreEqual(correlationId, message2.NMSCorrelationID, "Received the wrong correlation ID message."); + Assert.IsInstanceOf(typeof(ITextMessage), message2); + Assert.AreEqual(((ITextMessage)message2).Text, message.Text); + } + finally + { + if(null != consumer) + { + consumer.Close(); + } + } + } + } + } + } + } +} Modified: activemq/activemq-dotnet/Apache.NMS.EMS/branches/1.5.x/vs2008-ems-test.csproj URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.EMS/branches/1.5.x/vs2008-ems-test.csproj?rev=1172914&r1=1172913&r2=1172914&view=diff ============================================================================== --- activemq/activemq-dotnet/Apache.NMS.EMS/branches/1.5.x/vs2008-ems-test.csproj (original) +++ activemq/activemq-dotnet/Apache.NMS.EMS/branches/1.5.x/vs2008-ems-test.csproj Tue Sep 20 00:11:02 2011 @@ -75,6 +75,7 @@ +