activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r826034 - in /activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp: Connection.cs Transport/ResponseCorrelator.cs Transport/Tcp/TcpTransport.cs
Date Fri, 16 Oct 2009 18:49:59 GMT
Author: tabish
Date: Fri Oct 16 18:49:59 2009
New Revision: 826034

URL: http://svn.apache.org/viewvc?rev=826034&view=rev
Log:
https://issues.apache.org/activemq/browse/AMQNET-179

Remove the try/catch in the TcpTransports oneway method and just throw the error.  Error on
send is in all cases treated as non-recoverable so throwing here is the right thing to do,
the wrapped transports each get a change to process the error and remove any resources.  Connection
catches errors on send and ensures that only NMSExceptions are thrown from there.  When used
in a Failover transport this allows the logic in the oneway method to work more effectively
instead of relying on the exception listener callback to trip the reconnect logic.

Modified:
    activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Connection.cs
    activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Transport/ResponseCorrelator.cs
    activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Transport/Tcp/TcpTransport.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=826034&r1=826033&r2=826034&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 Fri Oct
16 18:49:59 2009
@@ -411,26 +411,49 @@
 
 		public Response SyncRequest(Command command)
 		{
-			return SyncRequest(command, this.RequestTimeout);
+            try
+            {
+                return SyncRequest(command, this.RequestTimeout);
+            }
+            catch(Exception ex)
+            {
+                throw NMSExceptionSupport.Create(ex);
+            }
 		}
 
 		public Response SyncRequest(Command command, TimeSpan requestTimeout)
 		{
 			CheckConnected();
-			Response response = transport.Request(command, requestTimeout);
-			if(response is ExceptionResponse)
-			{
-				ExceptionResponse exceptionResponse = (ExceptionResponse) response;
-				BrokerError brokerError = exceptionResponse.Exception;
-				throw new BrokerException(brokerError);
-			}
-			return response;
+
+            try
+            {
+    			Response response = transport.Request(command, requestTimeout);
+    			if(response is ExceptionResponse)
+    			{
+    				ExceptionResponse exceptionResponse = (ExceptionResponse) response;
+    				BrokerError brokerError = exceptionResponse.Exception;
+    				throw new BrokerException(brokerError);
+    			}
+    			return response;
+            }
+            catch(Exception ex)
+            {
+                throw NMSExceptionSupport.Create(ex);
+            }
 		}
 
 		public void Oneway(Command command)
 		{
 			CheckConnected();
-			transport.Oneway(command);
+
+            try
+            {
+                transport.Oneway(command);
+            }
+            catch(Exception ex)
+            {
+                throw NMSExceptionSupport.Create(ex);                
+            }
 		}
 
 		public void DisposeOf(DataStructure objectId)

Modified: activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Transport/ResponseCorrelator.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Transport/ResponseCorrelator.cs?rev=826034&r1=826033&r2=826034&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Transport/ResponseCorrelator.cs
(original)
+++ activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Transport/ResponseCorrelator.cs
Fri Oct 16 18:49:59 2009
@@ -55,7 +55,7 @@
 			requestMap.Clear();
 		}
 
-		int GetNextCommandId()
+		internal int GetNextCommandId()
 		{
             return Interlocked.Increment(ref nextCommandId);
 		}
@@ -80,7 +80,6 @@
 			requestMap[commandId] = future;
 			next.Oneway(command);
 			return future;
-
 		}
 
 		public override Response Request(Command command, TimeSpan timeout)

Modified: activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Transport/Tcp/TcpTransport.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Transport/Tcp/TcpTransport.cs?rev=826034&r1=826033&r2=826034&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Transport/Tcp/TcpTransport.cs
(original)
+++ activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Transport/Tcp/TcpTransport.cs
Fri Oct 16 18:49:59 2009
@@ -114,37 +114,17 @@
 		{
 			lock(myLock)
 			{
-				try
+				if(closed.Value)
 				{
-					if(closed.Value)
-					{
-						throw new InvalidOperationException("Error writing to broker.  Transport connection
is closed.");
-					}
-
-					if(command is ShutdownInfo)
-					{
-						seenShutdown = true;
-					}
-
-					Wireformat.Marshal(command, socketWriter);
-					//jdg socketWriter.Flush();
+					throw new InvalidOperationException("Error writing to broker.  Transport connection
is closed.");
 				}
-				catch(Exception ex)
+
+				if(command is ShutdownInfo)
 				{
-					if(command.ResponseRequired)
-					{
-						// Make sure that something higher up doesn't get blocked.
-						// Respond with an exception.
-						ExceptionResponse er = new ExceptionResponse();
-						BrokerError error = new BrokerError();
-
-						error.Message = "Transport connection error: " + ex.Message;
-						error.ExceptionClass = ex.ToString();
-						er.Exception = error;
-						er.CorrelationId = command.CommandId;
-						commandHandler(this, er);
-					}
+					seenShutdown = true;
 				}
+
+				Wireformat.Marshal(command, socketWriter);
 			}
 		}
 



Mime
View raw message