activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gaurav Hariani <>
Subject Orphan connections from .NET clients
Date Wed, 06 Jun 2007 18:04:02 GMT
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 

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");


           } finally {
               Console.WriteLine("Connection Closed");

View raw message