activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dris <chris_be...@hotmail.com>
Subject Re: Orphan connections from .NET clients
Date Tue, 26 Jun 2007 15:19:04 GMT

OK, I compiled the following against a recent-ish version of NMS. I haven't
done a more recent compile because as I pointed out in the NMS issue tracker
there was a bug in the use of selectors which I had fixed in my source but
which hadn't been fixed in the SVN Repo (though it might have been very
recently). This is just your original post with your disconnect logic shoved
in the finally block. When I monitor this in JConsole the connection gets
cleaned up fine and there is no Connection folder under localhost in the
MBeans treeview. Hope this helps (though obviously it doesn't I guess!).
Happy to mail you my NMS.dll and ActiveMQ.dll compiles for you to try.

Chris


using System;
using System.Threading;
using NMS;

namespace ActiveMQ
{
	class TestMain
	{
		static void Main(string[] args)
		{
			Uri uri = new Uri("tcp://bhw152:61616");
			
			ConnectionFactory factory = new ConnectionFactory(uri);
			
			IConnection connection = null;
			ISession session = null;
			
			try
			{
				connection = factory.CreateConnection();
				Console.WriteLine("Connection Created");
				
				connection.ClientId = "[test1] " + connection.ClientId;
				
				session = connection.CreateSession();
				Console.WriteLine("Session Created");
				
				Thread.Sleep(10000);
			}
			finally
			{
				try
				{
					if (session != null)
					{
					    session.Close();
					    session.Dispose();
					}
					
					if (connection != null)
					{
					    connection.Dispose();
					}
				}
				catch (Exception ex)
				{
					Console.WriteLine("ERROR DISCONNECTING: " + ex.StackTrace);
				}
				Console.WriteLine("Connection Closed");
			}
		}
	}
}
-- 
View this message in context: http://www.nabble.com/Orphan-connections-from-.NET-clients-tf3879502s2354.html#a11307469
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Mime
View raw message