You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by ta...@apache.org on 2013/05/16 21:19:30 UTC

svn commit: r1483517 - /activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/MessageProducer.cs

Author: tabish
Date: Thu May 16 19:19:30 2013
New Revision: 1483517

URL: http://svn.apache.org/r1483517
Log:
Few small cleanups

Modified:
    activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/MessageProducer.cs

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=1483517&r1=1483516&r2=1483517&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 Thu May 16 19:19:30 2013
@@ -28,7 +28,7 @@ namespace Apache.NMS.ActiveMQ
 	/// </summary>
 	public class MessageProducer : IMessageProducer
 	{
-		private Session session;
+		private readonly Session session;
 		private readonly MemoryUsage usage = null;
 		private readonly object closedLock = new object();
 		private bool closed = false;
@@ -59,17 +59,20 @@ namespace Apache.NMS.ActiveMQ
 
 			// If the destination contained a URI query, then use it to set public
 			// properties on the ProducerInfo
-			if(destination != null && destination.Options != null)
+			if (destination != null && destination.Options != null)
 			{
 				URISupport.SetProperties(this.info, destination.Options, "producer.");
 			}
 
 			// Version Three and higher will send us a ProducerAck, but only if we
 			// have a set producer window size.
-			if(session.Connection.ProtocolVersion >= 3 && this.info.WindowSize > 0)
+			if (session.Connection.ProtocolVersion >= 3 && this.info.WindowSize > 0)
 			{
-				Tracer.Debug("MessageProducer created with a Window Size of: " + this.info.WindowSize);
-				this.usage = new MemoryUsage(this.info.WindowSize);
+                if (Tracer.IsDebugEnabled)
+                {
+                    Tracer.Debug("MessageProducer created with a Window Size of: " + this.info.WindowSize);
+                }
+			    this.usage = new MemoryUsage(this.info.WindowSize);
 			}
 		}
 
@@ -91,18 +94,12 @@ namespace Apache.NMS.ActiveMQ
 				return;
 			}
 
-			if(disposing)
-			{
-				// Dispose managed code here.
-			}
-
 			try
 			{
 				Close();
 			}
 			catch
 			{
-				// Ignore network errors.
 			}
 
 			disposed = true;
@@ -234,7 +231,7 @@ namespace Apache.NMS.ActiveMQ
 			
 			// Ensure that the source message contains the NMSMessageId of the transformed
 			// message for correlation purposes.
-			if (!Object.ReferenceEquals(message, activeMessage))
+			if (!ReferenceEquals(message, activeMessage))
 			{
 				message.NMSMessageId = activeMessage.NMSMessageId;				
 			}
@@ -361,9 +358,12 @@ namespace Apache.NMS.ActiveMQ
 
 		internal void OnProducerAck(ProducerAck ack)
 		{
-			Tracer.Debug("Received ProducerAck for Message of Size = {" + ack.Size + "}" );
+            if (Tracer.IsDebugEnabled)
+            {
+                Tracer.Debug("Received ProducerAck for Message of Size = {" + ack.Size + "}");
+            }
 
-			if(this.usage != null)
+		    if(this.usage != null)
 			{
 				this.usage.DecreaseUsage( ack.Size );
 			}