Merged revision(s) 1172914 from activemq/activemq-dotnet/Apache.NMS.EMS/branches/1.5.x:
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.
........

diff --git a/src/main/csharp/MapMessage.cs b/src/main/csharp/MapMessage.cs
index 2232421..49b642f 100644
--- a/src/main/csharp/MapMessage.cs
+++ b/src/main/csharp/MapMessage.cs
@@ -87,16 +87,14 @@
 			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 @@
 

 				try

 				{

-					foreach(string itemName in EMSConvert.ToEnumerable(this.tibcoMapMessage.MapNames))

+					foreach(string itemName in this.tibcoMapMessage.GetMapNames())

 					{

 						keys.Add(itemName);

 					}

@@ -138,7 +136,7 @@
 

 				try

 				{

-					foreach(string itemName in EMSConvert.ToEnumerable(this.tibcoMapMessage.MapNames))

+					foreach(string itemName in this.tibcoMapMessage.GetMapNames())

 					{

 						keys.Add(this.tibcoMapMessage.GetObject(itemName));

 					}

diff --git a/src/main/csharp/MessageConsumer.cs b/src/main/csharp/MessageConsumer.cs
index 16e227e..cf5ca6f 100644
--- a/src/main/csharp/MessageConsumer.cs
+++ b/src/main/csharp/MessageConsumer.cs
@@ -108,7 +108,16 @@
 				{

 					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();

 					}

 				}

diff --git a/src/test/csharp/ReqResponseTempQueue.cs b/src/test/csharp/ReqResponseTempQueue.cs
new file mode 100644
index 0000000..9d5da37
--- /dev/null
+++ b/src/test/csharp/ReqResponseTempQueue.cs
@@ -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();

+							}

+						}

+					}

+				}

+			}

+		}

+	}

+}

diff --git a/vs2008-ems-test.csproj b/vs2008-ems-test.csproj
index 5f2bdb7..1ddf024 100644
--- a/vs2008-ems-test.csproj
+++ b/vs2008-ems-test.csproj
@@ -75,6 +75,7 @@
   </ItemGroup>

   <ItemGroup>

     <Compile Include="src\test\csharp\CommonAssemblyInfo.cs" />

+    <Compile Include="src\test\csharp\ReqResponseTempQueue.cs" />

   </ItemGroup>

   <ItemGroup>

     <ProjectReference Include="vs2008-ems.csproj">