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

When the topic broker keep coming messages, cannot disconnect

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 1.7.0
    • None
    • ActiveMQ, NMS
    • None
    • Client: Windows 7 32 bit; DotNET framework 4.0
      Server: Centos OS 5.6; ActiveMQ 5.10

    • Important

    Description

      We have a production envrionment like below:
      1. Client UI start, subscribe to server, the topic
      2. That topic has a lot of messages coming, 60 messages per second
      3. But, we want to close the connect before close the UI
      4. After we debug into, found the process hang up at the session close portion.

      Sample code:

      public bool ReceiveUpdateMessageFromServer()
      {
      bool result = false;
      try
      {
      StartConnection();

      Console.WriteLine("Update connection started...");

      sessionUpdate = connectionRec.CreateSession(AcknowledgementMode.AutoAcknowledge);

      Console.WriteLine("Update session created...");

      if (!connectionRec.IsStarted)
      connectionRec.Start();

      if (this.strTesterID != "")

      { topicConsumer = sessionUpdate.GetTopic(this.strUpdateTopic); string strJMSSelector = "TESTERID='" + this.strTesterID + "'"; consumerUpdate = sessionUpdate.CreateConsumer(topicConsumer, strJMSSelector); }

      else if (consumerUpdate == null)

      { destinationRec = sessionUpdate.GetTopic(this.strUpdateTopic); consumerUpdate = sessionUpdate.CreateConsumer(destinationRec); }

      Console.WriteLine("Consumer started ...");

      Console.WriteLine("Update session started...");

      consumerUpdate.Listener += (message =>

      { OnUpdateMessageReceived(message); }

      );

      result = true;
      }
      catch (Exception exMsgRec)
      {
      if (!exMsgRec.Message.Contains("already connected"))

      { StopReceiveUpdateMessageFromServer(); throw exMsgRec; }

      }
      finally
      {
      }

      return result;
      }

      public void StopReceiveUpdateMessageFromServer()
      {
      try
      {
      #region Consumer Close

      if (consumerUpdate != null)
      {
      try

      { consumerUpdate.Close(); Console.WriteLine("Consumer stopped..."); }

      catch (Exception exClose)

      { if (exClose.Message != "Object reference not set to an instance of an object.") throw exClose; }

      consumerUpdate.Dispose();
      consumerUpdate = null;

      }

      #endregion

      #region Session Close

      if (sessionUpdate != null)
      {
      try
      { sessionUpdate.Close(); Console.WriteLine("Session stopped..."); }
      catch (Exception exClose)
      { if (exClose.Message != "Object reference not set to an instance of an object.") throw exClose; }

      //# The process hang up here, don't why
      sessionUpdate.Dispose();
      sessionUpdate = null;

      }

      #endregion

      #region Connection Close

      lock (this)
      {
      if (connectionRec != null)
      {
      try

      { connectionRec.Close(); Console.WriteLine("Connection stopped..."); }

      catch (Exception exClose)

      { if (exClose.Message != "Object reference not set to an instance of an object.") throw exClose; }

      connectionRec.Dispose();
      connectionRec = null;
      }
      }
      #endregion

      if (destinationRec != null)

      { destinationRec = null; }

      if (factoryRec != null)

      { factoryRec = null; }

      }
      catch (Exception exRecMessage)

      { if (exRecMessage.Message != "Object reference not set to an instance of an object.") throw exRecMessage; }

      }

      Attachments

        Activity

          People

            Unassigned Unassigned
            janebaba007 JIANPING
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: