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

Closing a consumer does not unblock receive call

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.1.0
    • 1.1.0
    • ActiveMQ
    • None
    • windows xp profesional

    Description

      calling the close method of a cosumer while this has a pending receive call blocked does not unblock returning null.

      sample code (C#)

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

      namespace simpleConsumer
      {
      class Program
      {

      private static bool _exit = false;
      private static IMessageConsumer _consumer;

      static void Main(string[] args)
      {
      Apache.NMS.ActiveMQ.ConnectionFactory connectionFactory = new ConnectionFactory("tcp://172.18.141.102:61616");
      Apache.NMS.IConnection connection = connectionFactory.CreateConnection();
      connection.Start();
      Apache.NMS.ISession session = connection.CreateSession();
      Apache.NMS.ActiveMQ.Commands.ActiveMQTopic inputTopic = new Apache.NMS.ActiveMQ.Commands.ActiveMQTopic("test.topic");
      _consumer = session.CreateConsumer(inputTopic, "2>1");
      Thread _receiveThread = new Thread(_receiveLoop);
      _receiveThread.Start();
      while (!_exit)
      {
      String command = Console.ReadLine();
      if (command == "exit")

      { _exit = true; }

      }
      _consumer.Close();
      _receiveThread.Join();
      }

      private static void _receiveLoop()
      {
      while (!_exit)

      { Apache.NMS.ActiveMQ.Commands.ActiveMQTextMessage message = (Apache.NMS.ActiveMQ.Commands.ActiveMQTextMessage)_consumer.Receive(); Console.WriteLine(message.Content.ToString() + " [looping...]"); }

      }
      }
      }

      Attachments

        Activity

          People

            tabish Timothy A. Bish
            crive Marco Crivellaro
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: