Uploaded image for project: 'ActiveMQ .Net'
  1. ActiveMQ .Net
  2. AMQNET-301

Session.CreateSession creates a thread that never gets disposed.

Attach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Critical
    • Resolution: Fixed
    • 1.2.0, 1.3.0, 1.4.0, 1.4.1
    • 1.5.0
    • NMS
    • None
    • Tested on Windows 7 and Windows Server 2008

    Description

      The Factory.CreateSession function creates a thread that never gets disposed.

      If you run the code in visual studio and step through each line you will notice that on the first iteration of the loop two threads are created on the factory.CreateConnection line. Only one is cleaned up. Then each iteration after one thread is created on factory.CreateSession and is cleaned up correctly, but a second on is created on connection.CreateSession and is not cleaned up. Every iteration will then make a thread on connection.CreateSession that does not get cleaned up.

      Interesting, this occurs with every version I've tested except the old 1.1 version. That version cleans up correctly.

      CODE TO REPRODUCE THE ISSUE-----------------------------------------------------------------

      using System;
      using System.Threading;
      using Apache.NMS;
      using Apache.NMS.ActiveMQ;
      using Apache.NMS.ActiveMQ.Commands;

      namespace ThreadTest
      {
      internal class Program
      {
      private static void Main(string[] args)
      {
      while (true)
      {
      Console.WriteLine("sending");

      //"tcp://localhost:61616/"
      IConnectionFactory factory = new ConnectionFactory("tcp://localhost:61616/");
      using (IConnection connection = factory.CreateConnection())
      {
      //Create the Session
      using (ISession session = connection.CreateSession())

      { //Create the Producer for the topic/queue IMessageProducer prod = session.CreateProducer(new ActiveMQTopic("KELLYTEST")); ITextMessage msg = prod.CreateTextMessage(); msg.Text = "test"; prod.Send(msg, MsgDeliveryMode.NonPersistent, MsgPriority.Normal, TimeSpan.MinValue); }

      }

      Thread.Sleep(5000);
      }
      }
      }
      }

      Attachments

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            jgomes Jim Gomes
            kelias Kelly Elias
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Issue deployment