If not, here's a quick class I hacked together to stop the inactive connections - just give your JMX url as a command line argument. Not guarantees provided with this code!
package com.ubs.eq.speed; import java.util.Hashtable; import java.util.Set; import javax.management.MBeanServerConnection; import javax.management.ObjectInstance; import javax.management.ObjectName; import javax.management.remote.JMXConnector; import javax.management.remote.JMXConnectorFactory; import javax.management.remote.JMXServiceURL; public class OrphanConnectionCleaner { private static String url; public static void main(String[] args) throws Exception { if(args.length < 1) throw new IllegalArgumentException("URL argument must be provided"); url = args[0]; JMXServiceURL address = new JMXServiceURL(url); JMXConnector connector = JMXConnectorFactory.connect(address); MBeanServerConnection mbs = connector.getMBeanServerConnection(); Set s = mbs.queryMBeans(new ObjectName("org.apache.activemq:BrokerName=localhost,Type=Connection,ConnectorName=openwire,*"), null); for(Object o : s) { if(o instanceof ObjectInstance) { ObjectInstance i = (ObjectInstance)o; ObjectName n = i.getObjectName(); Hashtable keys = n.getKeyPropertyList(); if(keys.containsKey("Connection")) { try { Object connectionId = mbs.getAttribute(n, "ConnectionId"); System.out.println("Not stopping connection " + connectionId + " - connection still active"); } catch (Exception ex) { try { System.out.println("Stopping connection"); mbs.invoke(n, "stop", new Object[]{}, new String[]{}); } catch(Exception ignore) { ignore.printStackTrace(); } } } } } } } Jim_Cross wrote: > > Gaurav, > > Did you ever find a workaround for this? I've hit the same problem with > NMS and ActiveMQ 4.1.1 (also seems to affect 4.1.0 but not 4.0.2), and it > looks like it could be a show stopper for us. > > Cheers, > > Jim > > > Gaurav Hariani-2 wrote: >> >> yes >> >> Hiram Chirino wrote: >>> Odd. look like a bug. You using 4.1.1? >>> >>> >>> On 6/6/07, Gaurav Hariani <[EMAIL PROTECTED]> wrote: >>>> Since James and Hiram are back on the list ... I thought I'd repost >>>> this- >>>> >>>> We are facing a problem of orphan connections to ActiveMQ. A simple >>>> .NET >>>> client that only creates a connection/session and then closes and >>>> exits, >>>> still shows up in jconsole. >>>> It is possible to stop it manually in jconsole. >>>> >>>> Below is an example to reproduce the problem: >>>> >>>> >>>> The following code creates a connection to an OpenWire transport >>>> connector, waits for 1 second and then closes the session/connection. >>>> Looking at JConsole ... ActiveMQ reports the connection as open. Too >>>> many open connections and ActiveMQ stops processing messages. >>>> >>>> However if the connection is not closed by the application and the >>>> application is killed using Ctrl-C ... then ActiveMQ closes the >>>> connections. >>>> >>>> Is there something obvious that I'm doing wrong or is this a bug in the >>>> TcpTransport code? >>>> >>>> >>>> >>>> using System; >>>> using System.Threading; >>>> using NMS; >>>> >>>> namespace ActiveMQ { >>>> class TestMain { >>>> >>>> static void Main(string[] args) { >>>> >>>> Uri uri = new Uri("tcp://activemqserver: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(1000); >>>> >>>> } finally { >>>> session.Close(); >>>> connection.Close(); >>>> Console.WriteLine("Connection Closed"); >>>> } >>>> } >>>> } >>>> } >>>> >>> >>> >> >> > > -- View this message in context: http://www.nabble.com/Orphan-connections-from-.NET-clients-tf3879502s2354.html#a11229810 Sent from the ActiveMQ - User mailing list archive at Nabble.com.