activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r989954 - in /activemq/activemq-dotnet: Apache.NMS.ActiveMQ/trunk/src/main/csharp/ Apache.NMS.ActiveMQ/trunk/src/main/csharp/Transport/ Apache.NMS.ActiveMQ/trunk/src/test/csharp/ Apache.NMS.Stomp/trunk/src/main/csharp/ Apache.NMS.Stomp/trun...
Date Thu, 26 Aug 2010 22:12:51 GMT
Author: tabish
Date: Thu Aug 26 22:12:51 2010
New Revision: 989954

URL: http://svn.apache.org/viewvc?rev=989954&view=rev
Log:
Fix for: https://issues.apache.org/activemq/browse/AMQNET-278

Added:
    activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/RequestTimedOutException.cs
  (with props)
    activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/RequestTimedOutException.cs
  (with props)
Modified:
    activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Transport/FutureResponse.cs
    activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/MessageProducerTest.cs
    activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Transport/FutureResponse.cs

Added: activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/RequestTimedOutException.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/RequestTimedOutException.cs?rev=989954&view=auto
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/RequestTimedOutException.cs
(added)
+++ activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/RequestTimedOutException.cs
Thu Aug 26 22:12:51 2010
@@ -0,0 +1,47 @@
+/*
+ * 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.Text;
+
+using Apache.NMS;
+
+namespace Apache.NMS.ActiveMQ
+{
+	/// <summary>
+	/// Exception thrown when an Request times out.
+	/// </summary>
+	public class RequestTimedOutException : IOException
+	{
+		public RequestTimedOutException()
+			: base("IO Exception failed with missing exception log")
+		{
+		}
+
+		public RequestTimedOutException(String msg)
+			: base(msg)
+		{
+		}
+
+		public RequestTimedOutException(String msg, Exception inner)
+			: base(msg, inner)
+		{
+		}
+	}
+}
+
+

Propchange: activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/RequestTimedOutException.cs
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/RequestTimedOutException.cs
------------------------------------------------------------------------------
    svn:executable = *

Modified: activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Transport/FutureResponse.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Transport/FutureResponse.cs?rev=989954&r1=989953&r2=989954&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Transport/FutureResponse.cs
(original)
+++ activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Transport/FutureResponse.cs
Thu Aug 26 22:12:51 2010
@@ -52,11 +52,23 @@ namespace Apache.NMS.ActiveMQ.Transport
 
 				try
 				{
-					latch.await(maxWait);
+					if(!latch.await(maxWait) && response == null)
+					{
+						throw new RequestTimedOutException();
+					}
 				}
-				catch (Exception e)
+				catch(RequestTimedOutException e)
+				{
+					Tracer.Error("Caught Timeout Exception while waiting on monitor: " + e);
+					throw;
+				}
+				catch(Exception e)
+				{
+					Tracer.Error("Caught Exception while waiting on monitor: " + e);
+				}
+				
+				if(response == null && maxWait.TotalMilliseconds > 0)
 				{
-					Tracer.Error("Caught while waiting on monitor: " + e);
 				}
 
 				lock(latch)

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=989954&r1=989953&r2=989954&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
Thu Aug 26 22:12:51 2010
@@ -43,7 +43,15 @@ namespace Apache.NMS.ActiveMQ.Test
 					{
 						DateTime start = DateTime.Now;
 
-						producer.Send(message);
+						try
+						{
+							producer.Send(message);
+							Assert.Fail("Expected a RequestTimedOutException");
+						}
+						catch(RequestTimedOutException)
+						{
+						}
+						
 						TimeSpan elapsed = DateTime.Now - start;
 						// Make sure we timed out.
 						Assert.GreaterOrEqual((int) elapsed.TotalMilliseconds, timeout - 10, "Did not reach
timeout limit.");

Added: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/RequestTimedOutException.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/RequestTimedOutException.cs?rev=989954&view=auto
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/RequestTimedOutException.cs
(added)
+++ activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/RequestTimedOutException.cs
Thu Aug 26 22:12:51 2010
@@ -0,0 +1,47 @@
+/*
+ * 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.Text;
+
+using Apache.NMS;
+
+namespace Apache.NMS.Stomp
+{
+    /// <summary>
+    /// Exception thrown when an Request times out.
+    /// </summary>
+    public class RequestTimedOutException : IOException
+    {
+        public RequestTimedOutException()
+            : base("IO Exception failed with missing exception log")
+        {
+        }
+
+        public RequestTimedOutException(String msg)
+            : base(msg)
+        {
+        }
+
+        public RequestTimedOutException(String msg, Exception inner)
+            : base(msg, inner)
+        {
+        }
+    }
+}
+
+

Propchange: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/RequestTimedOutException.cs
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/RequestTimedOutException.cs
------------------------------------------------------------------------------
    svn:executable = *

Modified: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Transport/FutureResponse.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Transport/FutureResponse.cs?rev=989954&r1=989953&r2=989954&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Transport/FutureResponse.cs
(original)
+++ activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Transport/FutureResponse.cs
Thu Aug 26 22:12:51 2010
@@ -23,67 +23,72 @@ using Apache.NMS.Util;
 
 namespace Apache.NMS.Stomp.Transport
 {
-	/// <summary>
-	/// Handles asynchronous responses
-	/// </summary>
-	public class FutureResponse
-	{
-		private TimeSpan maxWait = TimeSpan.FromMilliseconds(Timeout.Infinite);
-		public TimeSpan ResponseTimeout
-		{
-			get { return maxWait; }
-			set { maxWait = value; }
-		}
-
-		private readonly CountDownLatch latch = new CountDownLatch(1);
-		private Response response;
-
-		public WaitHandle AsyncWaitHandle
-		{
-			get { return latch.AsyncWaitHandle; }
-		}
-
-		public Response Response
-		{
-			// Blocks the caller until a value has been set
-			get
-			{
-				lock(latch)
-				{
-					if(null != response)
-					{
-						return response;
-					}
-				}
-
-				try
-				{
-					if(!latch.await(maxWait))
-					{
-						// TODO: Throw timeout exception?
-					}
-				}
-				catch (Exception e)
-				{
-					Tracer.Error("Caught while waiting on monitor: " + e);
-				}
-
-				lock(latch)
-				{
-					return response;
-				}
-			}
-
-			set
-			{
-				lock(latch)
-				{
-					response = value;
-				}
-
-				latch.countDown();
-			}
-		}
-	}
+    /// <summary>
+    /// Handles asynchronous responses
+    /// </summary>
+    public class FutureResponse
+    {
+        private TimeSpan maxWait = TimeSpan.FromMilliseconds(Timeout.Infinite);
+        public TimeSpan ResponseTimeout
+        {
+            get { return maxWait; }
+            set { maxWait = value; }
+        }
+
+        private readonly CountDownLatch latch = new CountDownLatch(1);
+        private Response response;
+
+        public WaitHandle AsyncWaitHandle
+        {
+            get { return latch.AsyncWaitHandle; }
+        }
+
+        public Response Response
+        {
+            // Blocks the caller until a value has been set
+            get
+            {
+                lock(latch)
+                {
+                    if(null != response)
+                    {
+                        return response;
+                    }
+                }
+
+                try
+                {
+                    if(!latch.await(maxWait) && response == null)
+                    {
+                        throw new RequestTimedOutException();
+                    }
+                }
+                catch(RequestTimedOutException e)
+                {
+                    Tracer.Error("Caught Timeout Exception while waiting on monitor: " +
e);
+                    throw;
+                }
+                catch(Exception e)
+                {
+                    Tracer.Error("Caught Exception while waiting on monitor: " + e);
+                }
+
+                lock(latch)
+                {
+                    return response;
+                }
+            }
+
+            set
+            {
+                lock(latch)
+                {
+                    response = value;
+                }
+
+                latch.countDown();
+            }
+        }
+    }
 }
 



Mime
View raw message