activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r1202412 - in /activemq/activemq-dotnet: Apache.NMS.ActiveMQ/trunk/src/main/csharp/ Apache.NMS.ActiveMQ/trunk/src/test/csharp/ Apache.NMS.EMS/trunk/src/main/csharp/ Apache.NMS.MSMQ/trunk/src/main/csharp/ Apache.NMS.Stomp/trunk/src/main/csha...
Date Tue, 15 Nov 2011 20:32:54 GMT
Author: tabish
Date: Tue Nov 15 20:32:54 2011
New Revision: 1202412

URL: http://svn.apache.org/viewvc?rev=1202412&view=rev
Log:
fix for: https://issues.apache.org/jira/browse/AMQNET-349

Modified:
    activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Connection.cs
    activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/TempDestinationTest.cs
    activemq/activemq-dotnet/Apache.NMS.EMS/trunk/src/main/csharp/Connection.cs
    activemq/activemq-dotnet/Apache.NMS.MSMQ/trunk/src/main/csharp/Connection.cs
    activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Connection.cs
    activemq/activemq-dotnet/Apache.NMS.ZMQ/trunk/src/main/csharp/Connection.cs
    activemq/activemq-dotnet/Apache.NMS/trunk/src/main/csharp/IConnection.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=1202412&r1=1202411&r2=1202412&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 Tue Nov
15 20:32:54 2011
@@ -630,6 +630,36 @@ namespace Apache.NMS.ActiveMQ
 			disposed = true;
 		}
 
+        public void PurgeTempDestinations()
+        {
+            if (this.tempDests == null || this.tempDests.Count == 0)
+            {
+                return;
+            }
+
+            lock(this.tempDests.SyncRoot)
+            {
+                Object[] keys = new Object[this.tempDests.Count];
+                this.tempDests.Keys.CopyTo(keys, 0);
+                foreach(ActiveMQTempDestination dest in keys)
+                {
+                    String localConnectionId = info.ConnectionId == null ? "" : info.ConnectionId.ToString();
+                    if (dest.PhysicalName.Contains(localConnectionId))
+                    {
+                        try
+                        {
+                            DeleteTemporaryDestination(dest);
+                        }
+                        catch
+                        {
+                            // The destination may still be in use in which case its
+                            // ok that it is not deleted now.
+                        }
+                    }
+                }
+            }
+        }
+
 		// Implementation methods
 
 		/// <summary>
@@ -1124,10 +1154,6 @@ namespace Apache.NMS.ActiveMQ
 			return destination;
 		}
 
-		protected void CreateTemporaryDestination(ActiveMQDestination tempDestination)
-		{
-		}
-
 		public void DeleteTemporaryDestination(IDestination destination)
 		{
             CheckClosedOrFailed();

Modified: activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/TempDestinationTest.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/TempDestinationTest.cs?rev=1202412&r1=1202411&r2=1202412&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/TempDestinationTest.cs
(original)
+++ activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/TempDestinationTest.cs
Tue Nov 15 20:32:54 2011
@@ -24,6 +24,7 @@ using Apache.NMS;
 using Apache.NMS.Test;
 using Apache.NMS.Util;
 using Apache.NMS.Policies;
+using Apache.NMS.ActiveMQ.Commands;
 using NUnit.Framework;
 
 namespace Apache.NMS.ActiveMQ.Test
@@ -294,6 +295,74 @@ namespace Apache.NMS.ActiveMQ.Test
             }
         }
 
+        [Test]
+        public void TestConnectionCanPurgeTempDestinations()
+        {
+            Connection connection = CreateConnection() as Connection;
+            connections.Add(connection);
+            ISession session = connection.CreateSession(AcknowledgementMode.AutoAcknowledge);
+            IMessageConsumer advisoryConsumer = session.CreateConsumer(AdvisorySupport.TEMP_DESTINATION_COMPOSITE_ADVISORY_TOPIC);
+            advisoryConsumer.Listener += OnAdvisoryMessage;
+
+            connection.Start();
+
+            for(int i = 0; i < 10; ++i)
+            {
+                ITemporaryTopic tempTopic = session.CreateTemporaryTopic();
+                Tracer.Debug("Created TempDestination: " + tempTopic);
+            }
+
+            // Create one from an alternate connection, it shouldn't get purged
+            // so we should have one less removed than added entries.
+            Connection connection2 = CreateConnection() as Connection;
+            ISession session2 = connection2.CreateSession(AcknowledgementMode.AutoAcknowledge);
+            ITemporaryTopic tempTopic2 = session2.CreateTemporaryTopic();
+
+            Thread.Sleep(4000);
+            Assert.IsTrue(tempDestsAdded.Count == 11);
+
+            connection.PurgeTempDestinations();
+
+            Thread.Sleep(4000);
+            Assert.IsTrue(tempDestsRemoved.Count == 10);
+        }
+
+        private readonly IList tempDestsAdded = ArrayList.Synchronized(new ArrayList());
+        private readonly IList tempDestsRemoved = ArrayList.Synchronized(new ArrayList());
+
+        private void OnAdvisoryMessage(IMessage msg)
+        {
+            Message message = msg as Message;
+            DestinationInfo destInfo = message.DataStructure as DestinationInfo;
+
+            if(destInfo != null)
+            {
+                ActiveMQDestination dest = destInfo.Destination;
+                if(!dest.IsTemporary)
+                {
+                    return;
+                }
+    
+                ActiveMQTempDestination tempDest = dest as ActiveMQTempDestination;
+                if(destInfo.OperationType == DestinationInfo.ADD_OPERATION_TYPE)
+                {
+                    if(Tracer.IsDebugEnabled)
+                    {
+                        Tracer.Debug("Connection adding: " + tempDest);
+                    }
+                    this.tempDestsAdded.Add(tempDest);
+                }
+                else if(destInfo.OperationType == DestinationInfo.REMOVE_OPERATION_TYPE)
+                {
+                    if(Tracer.IsDebugEnabled)
+                    {
+                        Tracer.Debug("Connection removing: " + tempDest);
+                    }
+                    this.tempDestsRemoved.Add(tempDest);
+                }
+            }
+        }
+
     }
 }
 

Modified: activemq/activemq-dotnet/Apache.NMS.EMS/trunk/src/main/csharp/Connection.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.EMS/trunk/src/main/csharp/Connection.cs?rev=1202412&r1=1202411&r2=1202412&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.EMS/trunk/src/main/csharp/Connection.cs (original)
+++ activemq/activemq-dotnet/Apache.NMS.EMS/trunk/src/main/csharp/Connection.cs Tue Nov 15
20:32:54 2011
@@ -20,320 +20,324 @@ using Apache.NMS.Util;
 
 namespace Apache.NMS.EMS
 {
-	/// <summary>
-	/// Represents a NMS connection to TIBCO.
-	/// </summary>
-	///
-	public class Connection : Apache.NMS.IConnection
-	{
-		private Apache.NMS.AcknowledgementMode acknowledgementMode;
-		public readonly TIBCO.EMS.Connection tibcoConnection;
-		private IRedeliveryPolicy redeliveryPolicy;
-		private ConnectionMetaData metaData = null;
-		private readonly Atomic<bool> started = new Atomic<bool>(false);
-		private bool closed = false;
-		private bool disposed = false;
-
-		public Connection(TIBCO.EMS.Connection cnx)
-		{
-			this.tibcoConnection = cnx;
-			this.tibcoConnection.ExceptionHandler += this.HandleTibcoException;
-		}
-
-		~Connection()
-		{
-			Dispose(false);
-		}
-
-		#region IStartable Members
-
-		/// <summary>
-		/// Starts message delivery for this connection.
-		/// </summary>
-		public void Start()
-		{
-			if(started.CompareAndSet(false, true))
-			{
-				try
-				{
-					this.tibcoConnection.Start();
-				}
-				catch(Exception ex)
-				{
-					ExceptionUtil.WrapAndThrowNMSException(ex);
-				}
-			}
-		}
-
-		public bool IsStarted
-		{
-			get { return this.started.Value; }
-		}
-
-		#endregion
-
-		#region IStoppable Members
-
-		/// <summary>
-		/// Stop message delivery for this connection.
-		/// </summary>
-		public void Stop()
-		{
-			try
-			{
-				if(started.CompareAndSet(true, false))
-				{
-					this.tibcoConnection.Stop();
-				}
-			}
-			catch(Exception ex)
-			{
-				ExceptionUtil.WrapAndThrowNMSException(ex);
-			}
-		}
-
-		#endregion
-
-		#region IConnection Members
-
-		/// <summary>
-		/// Creates a new session to work on this connection
-		/// </summary>
-		public Apache.NMS.ISession CreateSession()
-		{
-			return CreateSession(acknowledgementMode);
-		}
-
-		/// <summary>
-		/// Creates a new session to work on this connection
-		/// </summary>
-		public Apache.NMS.ISession CreateSession(Apache.NMS.AcknowledgementMode mode)
-		{
-			try
-			{
-				bool isTransacted = (Apache.NMS.AcknowledgementMode.Transactional == mode);
-				return EMSConvert.ToNMSSession(this.tibcoConnection.CreateSession(isTransacted,
-																  EMSConvert.ToSessionMode(mode)));
-			}
-			catch(Exception ex)
-			{
-				ExceptionUtil.WrapAndThrowNMSException(ex);
-				return null;
-			}
-		}
-
-		public void Close()
-		{
-			lock(this)
-			{
-				if(closed)
-				{
-					return;
-				}
-
-				try
-				{
-					this.tibcoConnection.ExceptionHandler -= this.HandleTibcoException;
-					this.tibcoConnection.Stop();
-					this.tibcoConnection.Close();
-				}
-				catch(Exception ex)
-				{
-					ExceptionUtil.WrapAndThrowNMSException(ex);
-				}
-				finally
-				{
-					closed = true;
-				}
-			}
-		}
-
-		#endregion
-
-		#region IDisposable Members
-
-		public void Dispose()
-		{
-			Dispose(true);
-			GC.SuppressFinalize(this);
-		}
-
-		protected void Dispose(bool disposing)
-		{
-			if(disposed)
-			{
-				return;
-			}
-
-			if(disposing)
-			{
-				// Dispose managed code here.
-			}
-
-			try
-			{
-				Close();
-			}
-			catch
-			{
-				// Ignore errors.
-			}
-
-			disposed = true;
-		}
-
-		#endregion
-
-		#region Attributes
-
-		/// <summary>
-		/// The default timeout for network requests.
-		/// </summary>
-		public TimeSpan RequestTimeout
-		{
-			get { return Apache.NMS.NMSConstants.defaultRequestTimeout; }
-			set { }
-		}
-
-		public Apache.NMS.AcknowledgementMode AcknowledgementMode
-		{
-			get { return acknowledgementMode; }
-			set { acknowledgementMode = value; }
-		}
-
-		public string ClientId
-		{
-			get
-			{
-				try
-				{
-					return this.tibcoConnection.ClientID;
-				}
-				catch(Exception ex)
-				{
-					ExceptionUtil.WrapAndThrowNMSException(ex);
-					return null;
-				}
-			}
-			set
-			{
-				try
-				{
-					this.tibcoConnection.ClientID = value;
-				}
-				catch(Exception ex)
-				{
-					ExceptionUtil.WrapAndThrowNMSException(ex);
-				}
-			}
-		}
-
-		/// <summary>
-		/// Get/or set the redelivery policy for this connection.
-		/// </summary>
-		public IRedeliveryPolicy RedeliveryPolicy
-		{
-			get { return this.redeliveryPolicy; }
-			set { this.redeliveryPolicy = value; }
-		}
-
-		/// <summary>
-		/// Gets the Meta Data for the NMS Connection instance.
-		/// </summary>
-		public IConnectionMetaData MetaData
-		{
-			get { return this.metaData ?? (this.metaData = new ConnectionMetaData()); }
-		}
-
-		#endregion
-
-		/// <summary>
-		/// A delegate that can receive transport level exceptions.
-		/// </summary>
-		public event ExceptionListener ExceptionListener;
-
-		/// <summary>
-		/// An asynchronous listener that is notified when a Fault tolerant connection
-		/// has been interrupted.
-		/// </summary>
-		public event ConnectionInterruptedListener ConnectionInterruptedListener;
-
-		/// <summary>
-		/// An asynchronous listener that is notified when a Fault tolerant connection
-		/// has been resumed.
-		/// </summary>
-		public event ConnectionResumedListener ConnectionResumedListener;
-
-		private void HandleTibcoException(object sender, TIBCO.EMS.EMSExceptionEventArgs arg)
-		{
-			if(ExceptionListener != null)
-			{
-				ExceptionListener(arg.Exception);
-			}
-			else
-			{
-				Apache.NMS.Tracer.Error(arg.Exception);
-			}
-		}
-
-		private void HandleTransportInterrupted()
-		{
-			Tracer.Debug("Transport has been Interrupted.");
-
-			if(this.ConnectionInterruptedListener != null && !this.closed)
-			{
-				try
-				{
-					this.ConnectionInterruptedListener();
-				}
-				catch
-				{
-				}
-			}
-		}
-
-		private void HandleTransportResumed()
-		{
-			Tracer.Debug("Transport has resumed normal operation.");
-
-			if(this.ConnectionResumedListener != null && !this.closed)
-			{
-				try
-				{
-					this.ConnectionResumedListener();
-				}
-				catch
-				{
-				}
-			}
-		}
-
-		private ConsumerTransformerDelegate consumerTransformer;
-		/// <summary>
-		/// A Delegate that is called each time a Message is dispatched to allow the client to
do
-		/// any necessary transformations on the received message before it is delivered.  The
-		/// ConnectionFactory sets the provided delegate instance on each Connection instance that
-		/// is created from this factory, each connection in turn passes the delegate along to
each
-		/// Session it creates which then passes that along to the Consumers it creates.
-		/// </summary>
-		public ConsumerTransformerDelegate ConsumerTransformer
-		{
-			get { return this.consumerTransformer; }
-			set { this.consumerTransformer = value; }
-		}
-
-		private ProducerTransformerDelegate producerTransformer;
-		/// <summary>
-		/// A delegate that is called each time a Message is sent from this Producer which allows
-		/// the application to perform any needed transformations on the Message before it is sent.
-		/// The ConnectionFactory sets the provided delegate instance on each Connection instance
that
-		/// is created from this factory, each connection in turn passes the delegate along to
each
-		/// Session it creates which then passes that along to the Producers it creates.
-		/// </summary>
-		public ProducerTransformerDelegate ProducerTransformer
-		{
-			get { return this.producerTransformer; }
-			set { this.producerTransformer = value; }
-		}
-	}
+    /// <summary>
+    /// Represents a NMS connection to TIBCO.
+    /// </summary>
+    ///
+    public class Connection : Apache.NMS.IConnection
+    {
+        private Apache.NMS.AcknowledgementMode acknowledgementMode;
+        public readonly TIBCO.EMS.Connection tibcoConnection;
+        private IRedeliveryPolicy redeliveryPolicy;
+        private ConnectionMetaData metaData = null;
+        private readonly Atomic<bool> started = new Atomic<bool>(false);
+        private bool closed = false;
+        private bool disposed = false;
+
+        public Connection(TIBCO.EMS.Connection cnx)
+        {
+            this.tibcoConnection = cnx;
+            this.tibcoConnection.ExceptionHandler += this.HandleTibcoException;
+        }
+
+        ~Connection()
+        {
+            Dispose(false);
+        }
+
+        #region IStartable Members
+
+        /// <summary>
+        /// Starts message delivery for this connection.
+        /// </summary>
+        public void Start()
+        {
+            if(started.CompareAndSet(false, true))
+            {
+                try
+                {
+                    this.tibcoConnection.Start();
+                }
+                catch(Exception ex)
+                {
+                    ExceptionUtil.WrapAndThrowNMSException(ex);
+                }
+            }
+        }
+
+        public bool IsStarted
+        {
+            get { return this.started.Value; }
+        }
+
+        #endregion
+
+        #region IStoppable Members
+
+        /// <summary>
+        /// Stop message delivery for this connection.
+        /// </summary>
+        public void Stop()
+        {
+            try
+            {
+                if(started.CompareAndSet(true, false))
+                {
+                    this.tibcoConnection.Stop();
+                }
+            }
+            catch(Exception ex)
+            {
+                ExceptionUtil.WrapAndThrowNMSException(ex);
+            }
+        }
+
+        #endregion
+
+        #region IConnection Members
+
+        /// <summary>
+        /// Creates a new session to work on this connection
+        /// </summary>
+        public Apache.NMS.ISession CreateSession()
+        {
+            return CreateSession(acknowledgementMode);
+        }
+
+        /// <summary>
+        /// Creates a new session to work on this connection
+        /// </summary>
+        public Apache.NMS.ISession CreateSession(Apache.NMS.AcknowledgementMode mode)
+        {
+            try
+            {
+                bool isTransacted = (Apache.NMS.AcknowledgementMode.Transactional == mode);
+                return EMSConvert.ToNMSSession(this.tibcoConnection.CreateSession(isTransacted,
+                                                                  EMSConvert.ToSessionMode(mode)));
+            }
+            catch(Exception ex)
+            {
+                ExceptionUtil.WrapAndThrowNMSException(ex);
+                return null;
+            }
+        }
+
+        public void Close()
+        {
+            lock(this)
+            {
+                if(closed)
+                {
+                    return;
+                }
+
+                try
+                {
+                    this.tibcoConnection.ExceptionHandler -= this.HandleTibcoException;
+                    this.tibcoConnection.Stop();
+                    this.tibcoConnection.Close();
+                }
+                catch(Exception ex)
+                {
+                    ExceptionUtil.WrapAndThrowNMSException(ex);
+                }
+                finally
+                {
+                    closed = true;
+                }
+            }
+        }
+
+        public void PurgeTempDestinations()
+        {
+        }
+
+        #endregion
+
+        #region IDisposable Members
+
+        public void Dispose()
+        {
+            Dispose(true);
+            GC.SuppressFinalize(this);
+        }
+
+        protected void Dispose(bool disposing)
+        {
+            if(disposed)
+            {
+                return;
+            }
+
+            if(disposing)
+            {
+                // Dispose managed code here.
+            }
+
+            try
+            {
+                Close();
+            }
+            catch
+            {
+                // Ignore errors.
+            }
+
+            disposed = true;
+        }
+
+        #endregion
+
+        #region Attributes
+
+        /// <summary>
+        /// The default timeout for network requests.
+        /// </summary>
+        public TimeSpan RequestTimeout
+        {
+            get { return Apache.NMS.NMSConstants.defaultRequestTimeout; }
+            set { }
+        }
+
+        public Apache.NMS.AcknowledgementMode AcknowledgementMode
+        {
+            get { return acknowledgementMode; }
+            set { acknowledgementMode = value; }
+        }
+
+        public string ClientId
+        {
+            get
+            {
+                try
+                {
+                    return this.tibcoConnection.ClientID;
+                }
+                catch(Exception ex)
+                {
+                    ExceptionUtil.WrapAndThrowNMSException(ex);
+                    return null;
+                }
+            }
+            set
+            {
+                try
+                {
+                    this.tibcoConnection.ClientID = value;
+                }
+                catch(Exception ex)
+                {
+                    ExceptionUtil.WrapAndThrowNMSException(ex);
+                }
+            }
+        }
+
+        /// <summary>
+        /// Get/or set the redelivery policy for this connection.
+        /// </summary>
+        public IRedeliveryPolicy RedeliveryPolicy
+        {
+            get { return this.redeliveryPolicy; }
+            set { this.redeliveryPolicy = value; }
+        }
+
+        /// <summary>
+        /// Gets the Meta Data for the NMS Connection instance.
+        /// </summary>
+        public IConnectionMetaData MetaData
+        {
+            get { return this.metaData ?? (this.metaData = new ConnectionMetaData()); }
+        }
+
+        #endregion
+
+        /// <summary>
+        /// A delegate that can receive transport level exceptions.
+        /// </summary>
+        public event ExceptionListener ExceptionListener;
+
+        /// <summary>
+        /// An asynchronous listener that is notified when a Fault tolerant connection
+        /// has been interrupted.
+        /// </summary>
+        public event ConnectionInterruptedListener ConnectionInterruptedListener;
+
+        /// <summary>
+        /// An asynchronous listener that is notified when a Fault tolerant connection
+        /// has been resumed.
+        /// </summary>
+        public event ConnectionResumedListener ConnectionResumedListener;
+
+        private void HandleTibcoException(object sender, TIBCO.EMS.EMSExceptionEventArgs
arg)
+        {
+            if(ExceptionListener != null)
+            {
+                ExceptionListener(arg.Exception);
+            }
+            else
+            {
+                Apache.NMS.Tracer.Error(arg.Exception);
+            }
+        }
+
+        private void HandleTransportInterrupted()
+        {
+            Tracer.Debug("Transport has been Interrupted.");
+
+            if(this.ConnectionInterruptedListener != null && !this.closed)
+            {
+                try
+                {
+                    this.ConnectionInterruptedListener();
+                }
+                catch
+                {
+                }
+            }
+        }
+
+        private void HandleTransportResumed()
+        {
+            Tracer.Debug("Transport has resumed normal operation.");
+
+            if(this.ConnectionResumedListener != null && !this.closed)
+            {
+                try
+                {
+                    this.ConnectionResumedListener();
+                }
+                catch
+                {
+                }
+            }
+        }
+
+        private ConsumerTransformerDelegate consumerTransformer;
+        /// <summary>
+        /// A Delegate that is called each time a Message is dispatched to allow the client
to do
+        /// any necessary transformations on the received message before it is delivered.
 The
+        /// ConnectionFactory sets the provided delegate instance on each Connection instance
that
+        /// is created from this factory, each connection in turn passes the delegate along
to each
+        /// Session it creates which then passes that along to the Consumers it creates.
+        /// </summary>
+        public ConsumerTransformerDelegate ConsumerTransformer
+        {
+            get { return this.consumerTransformer; }
+            set { this.consumerTransformer = value; }
+        }
+
+        private ProducerTransformerDelegate producerTransformer;
+        /// <summary>
+        /// A delegate that is called each time a Message is sent from this Producer which
allows
+        /// the application to perform any needed transformations on the Message before it
is sent.
+        /// The ConnectionFactory sets the provided delegate instance on each Connection
instance that
+        /// is created from this factory, each connection in turn passes the delegate along
to each
+        /// Session it creates which then passes that along to the Producers it creates.
+        /// </summary>
+        public ProducerTransformerDelegate ProducerTransformer
+        {
+            get { return this.producerTransformer; }
+            set { this.producerTransformer = value; }
+        }
+    }
 }

Modified: activemq/activemq-dotnet/Apache.NMS.MSMQ/trunk/src/main/csharp/Connection.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.MSMQ/trunk/src/main/csharp/Connection.cs?rev=1202412&r1=1202411&r2=1202412&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.MSMQ/trunk/src/main/csharp/Connection.cs (original)
+++ activemq/activemq-dotnet/Apache.NMS.MSMQ/trunk/src/main/csharp/Connection.cs Tue Nov 15
20:32:54 2011
@@ -183,6 +183,10 @@ namespace Apache.NMS.MSMQ
             Dispose();
         }
 
+        public void PurgeTempDestinations()
+        {
+        }
+
         public void HandleException(Exception e)
         {
             if(ExceptionListener != null && !this.closed)

Modified: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Connection.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Connection.cs?rev=1202412&r1=1202411&r2=1202412&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Connection.cs (original)
+++ activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Connection.cs Tue Nov
15 20:32:54 2011
@@ -492,6 +492,10 @@ namespace Apache.NMS.Stomp
             disposed = true;
         }
 
+        public void PurgeTempDestinations()
+        {
+        }
+
         // Implementation methods
 
         /// <summary>

Modified: activemq/activemq-dotnet/Apache.NMS.ZMQ/trunk/src/main/csharp/Connection.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.ZMQ/trunk/src/main/csharp/Connection.cs?rev=1202412&r1=1202411&r2=1202412&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.ZMQ/trunk/src/main/csharp/Connection.cs (original)
+++ activemq/activemq-dotnet/Apache.NMS.ZMQ/trunk/src/main/csharp/Connection.cs Tue Nov 15
20:32:54 2011
@@ -20,206 +20,210 @@ using ZContext = ZMQ.Context;
 
 namespace Apache.NMS.ZMQ
 {
-	/// <summary>
-	/// Represents a NMS connection ZMQ.  
-	/// </summary>
-	///
-	public class Connection : IConnection
-	{
-		private AcknowledgementMode acknowledgementMode = AcknowledgementMode.AutoAcknowledge;
-		private IRedeliveryPolicy redeliveryPolicy;
-		private ConnectionMetaData metaData = null;
-		private bool closed = true;
-		private string clientId;
-		private Uri brokerUri;
-
-		/// <summary>
-		/// ZMQ context 
-		/// </summary>
-		static private ZContext _context = new ZContext(1);
-
-		/// <summary>
-		/// Starts message delivery for this connection.
-		/// </summary>
-		public void Start()
-		{
-			closed = false;
-		}
-
-		/// <summary>
-		/// This property determines if the asynchronous message delivery of incoming
-		/// messages has been started for this connection.
-		/// </summary>
-		public bool IsStarted
-		{
-			get { return !closed; }
-		}
-
-		/// <summary>
-		/// Stop message delivery for this connection.
-		/// </summary>
-		public void Stop()
-		{
-			closed = true;
-		}
-
-		/// <summary>
-		/// Creates a new session to work on this connection
-		/// </summary>
-		public ISession CreateSession()
-		{
-			return CreateSession(acknowledgementMode);
-		}
-
-		/// <summary>
-		/// Creates a new session to work on this connection
-		/// </summary>
-		public ISession CreateSession(AcknowledgementMode mode)
-		{
-			return new Session(this, mode);
-		}
-
-		public void Dispose()
-		{
-			Close();
-		}
-
-		public void Close()
-		{
-			Stop();
-		}
-
-		/// <summary>
-		/// The default timeout for network requests.
-		/// </summary>
-		public TimeSpan RequestTimeout
-		{
-			get { return NMSConstants.defaultRequestTimeout; }
-			set { }
-		}
-
-		public AcknowledgementMode AcknowledgementMode
-		{
-			get { return acknowledgementMode; }
-			set { acknowledgementMode = value; }
-		}
-
-		/// <summary>
-		/// Get/or set the broker Uri.
-		/// </summary>
-		public Uri BrokerUri
-		{
-			get { return brokerUri; }
-			set { brokerUri = value; }
-		}
-
-		/// <summary>
-		/// Get/or set the client Id
-		/// </summary>
-		public string ClientId
-		{
-			get { return clientId; }
-			set { clientId = value; }
-		}
-
-		/// <summary>
-		/// Get/or set the redelivery policy for this connection.
-		/// </summary>
-		public IRedeliveryPolicy RedeliveryPolicy
-		{
-			get { return this.redeliveryPolicy; }
-			set { this.redeliveryPolicy = value; }
-		}
-
-		private ConsumerTransformerDelegate consumerTransformer;
-		public ConsumerTransformerDelegate ConsumerTransformer
-		{
-			get { return this.consumerTransformer; }
-			set { this.consumerTransformer = value; }
-		}
-
-		private ProducerTransformerDelegate producerTransformer;
-		public ProducerTransformerDelegate ProducerTransformer
-		{
-			get { return this.producerTransformer; }
-			set { this.producerTransformer = value; }
-		}
-
-		/// <summary>
-		/// Gets ZMQ connection context
-		/// </summary>
-		static internal ZContext Context
-		{
-			get { return _context; }
-		}
-
-		/// <summary>
-		/// Gets the Meta Data for the NMS Connection instance.
-		/// </summary>
-		public IConnectionMetaData MetaData
-		{
-			get { return this.metaData ?? (this.metaData = new ConnectionMetaData()); }
-		}
-
-		/// <summary>
-		/// A delegate that can receive transport level exceptions.
-		/// </summary>
-		public event ExceptionListener ExceptionListener;
-
-		/// <summary>
-		/// An asynchronous listener that is notified when a Fault tolerant connection
-		/// has been interrupted.
-		/// </summary>
-		public event ConnectionInterruptedListener ConnectionInterruptedListener;
-
-		/// <summary>
-		/// An asynchronous listener that is notified when a Fault tolerant connection
-		/// has been resumed.
-		/// </summary>
-		public event ConnectionResumedListener ConnectionResumedListener;
-
-		public void HandleException(System.Exception e)
-		{
-			if(ExceptionListener != null && !this.closed)
-			{
-				ExceptionListener(e);
-			}
-			else
-			{
-				Tracer.Error(e);
-			}
-		}
-
-		public void HandleTransportInterrupted()
-		{
-			Tracer.Debug("Transport has been Interrupted.");
-
-			if(this.ConnectionInterruptedListener != null && !this.closed)
-			{
-				try
-				{
-					this.ConnectionInterruptedListener();
-				}
-				catch
-				{
-				}
-			}
-		}
-
-		public void HandleTransportResumed()
-		{
-			Tracer.Debug("Transport has resumed normal operation.");
-
-			if(this.ConnectionResumedListener != null && !this.closed)
-			{
-				try
-				{
-					this.ConnectionResumedListener();
-				}
-				catch
-				{
-				}
-			}
-		}
-	}
+    /// <summary>
+    /// Represents a NMS connection ZMQ.
+    /// </summary>
+    ///
+    public class Connection : IConnection
+    {
+        private AcknowledgementMode acknowledgementMode = AcknowledgementMode.AutoAcknowledge;
+        private IRedeliveryPolicy redeliveryPolicy;
+        private ConnectionMetaData metaData = null;
+        private bool closed = true;
+        private string clientId;
+        private Uri brokerUri;
+
+        /// <summary>
+        /// ZMQ context
+        /// </summary>
+        static private ZContext _context = new ZContext(1);
+
+        /// <summary>
+        /// Starts message delivery for this connection.
+        /// </summary>
+        public void Start()
+        {
+            closed = false;
+        }
+
+        /// <summary>
+        /// This property determines if the asynchronous message delivery of incoming
+        /// messages has been started for this connection.
+        /// </summary>
+        public bool IsStarted
+        {
+            get { return !closed; }
+        }
+
+        /// <summary>
+        /// Stop message delivery for this connection.
+        /// </summary>
+        public void Stop()
+        {
+            closed = true;
+        }
+
+        /// <summary>
+        /// Creates a new session to work on this connection
+        /// </summary>
+        public ISession CreateSession()
+        {
+            return CreateSession(acknowledgementMode);
+        }
+
+        /// <summary>
+        /// Creates a new session to work on this connection
+        /// </summary>
+        public ISession CreateSession(AcknowledgementMode mode)
+        {
+            return new Session(this, mode);
+        }
+
+        public void Dispose()
+        {
+            Close();
+        }
+
+        public void Close()
+        {
+            Stop();
+        }
+
+        public void PurgeTempDestinations()
+        {
+        }
+
+        /// <summary>
+        /// The default timeout for network requests.
+        /// </summary>
+        public TimeSpan RequestTimeout
+        {
+            get { return NMSConstants.defaultRequestTimeout; }
+            set { }
+        }
+
+        public AcknowledgementMode AcknowledgementMode
+        {
+            get { return acknowledgementMode; }
+            set { acknowledgementMode = value; }
+        }
+
+        /// <summary>
+        /// Get/or set the broker Uri.
+        /// </summary>
+        public Uri BrokerUri
+        {
+            get { return brokerUri; }
+            set { brokerUri = value; }
+        }
+
+        /// <summary>
+        /// Get/or set the client Id
+        /// </summary>
+        public string ClientId
+        {
+            get { return clientId; }
+            set { clientId = value; }
+        }
+
+        /// <summary>
+        /// Get/or set the redelivery policy for this connection.
+        /// </summary>
+        public IRedeliveryPolicy RedeliveryPolicy
+        {
+            get { return this.redeliveryPolicy; }
+            set { this.redeliveryPolicy = value; }
+        }
+
+        private ConsumerTransformerDelegate consumerTransformer;
+        public ConsumerTransformerDelegate ConsumerTransformer
+        {
+            get { return this.consumerTransformer; }
+            set { this.consumerTransformer = value; }
+        }
+
+        private ProducerTransformerDelegate producerTransformer;
+        public ProducerTransformerDelegate ProducerTransformer
+        {
+            get { return this.producerTransformer; }
+            set { this.producerTransformer = value; }
+        }
+
+        /// <summary>
+        /// Gets ZMQ connection context
+        /// </summary>
+        static internal ZContext Context
+        {
+            get { return _context; }
+        }
+
+        /// <summary>
+        /// Gets the Meta Data for the NMS Connection instance.
+        /// </summary>
+        public IConnectionMetaData MetaData
+        {
+            get { return this.metaData ?? (this.metaData = new ConnectionMetaData()); }
+        }
+
+        /// <summary>
+        /// A delegate that can receive transport level exceptions.
+        /// </summary>
+        public event ExceptionListener ExceptionListener;
+
+        /// <summary>
+        /// An asynchronous listener that is notified when a Fault tolerant connection
+        /// has been interrupted.
+        /// </summary>
+        public event ConnectionInterruptedListener ConnectionInterruptedListener;
+
+        /// <summary>
+        /// An asynchronous listener that is notified when a Fault tolerant connection
+        /// has been resumed.
+        /// </summary>
+        public event ConnectionResumedListener ConnectionResumedListener;
+
+        public void HandleException(System.Exception e)
+        {
+            if(ExceptionListener != null && !this.closed)
+            {
+                ExceptionListener(e);
+            }
+            else
+            {
+                Tracer.Error(e);
+            }
+        }
+
+        public void HandleTransportInterrupted()
+        {
+            Tracer.Debug("Transport has been Interrupted.");
+
+            if(this.ConnectionInterruptedListener != null && !this.closed)
+            {
+                try
+                {
+                    this.ConnectionInterruptedListener();
+                }
+                catch
+                {
+                }
+            }
+        }
+
+        public void HandleTransportResumed()
+        {
+            Tracer.Debug("Transport has resumed normal operation.");
+
+            if(this.ConnectionResumedListener != null && !this.closed)
+            {
+                try
+                {
+                    this.ConnectionResumedListener();
+                }
+                catch
+                {
+                }
+            }
+        }
+    }
 }

Modified: activemq/activemq-dotnet/Apache.NMS/trunk/src/main/csharp/IConnection.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS/trunk/src/main/csharp/IConnection.cs?rev=1202412&r1=1202411&r2=1202412&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS/trunk/src/main/csharp/IConnection.cs (original)
+++ activemq/activemq-dotnet/Apache.NMS/trunk/src/main/csharp/IConnection.cs Tue Nov 15 20:32:54
2011
@@ -166,5 +166,22 @@ namespace Apache.NMS
 		IConnectionMetaData MetaData{ get; }
 
 		#endregion
+
+        #region Connection Management methods
+
+        /// <summary>
+        /// For a long running Connection that creates many temp destinations
+        /// this method will close and destroy all previously created temp
+        /// destinations to reduce resource consumption.  This can be useful
+        /// when the Connection is pooled or otherwise used for long periods
+        /// of time.  Only locally created temp destinations should be removed
+        /// by this call.
+        /// NOTE: This is an optional operation and for NMS providers that
+        /// do not support this functionality the method should just return
+        /// without throwing any exceptions.
+        /// </summary>
+        void PurgeTempDestinations();
+
+        #endregion
 	}
 }



Mime
View raw message