activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sparky2708 <>
Subject Queue gets clogged in OpenWire.NET when using Listener
Date Fri, 04 Aug 2006 15:33:43 GMT

For one of the tests that I am doing I have an OpenWire.NET producer and
consumer that runs within Excel using a C# COM object to access ActiveMQ
using OpenWire.NET. It sends messages and then immediately consumes them.
When Excel quits on me I see that the messages get stuck on the queue
(through jconsole). When I restart Excel and res-subscribe my client I don't
get any messages even though messages are sitting on the queue. So my
OpenWire.NET code looks like (assume enable_async_receive is true):

 public void CreateConnection(string url)
                IConnectionFactory factory = new ConnectionFactory(new
                _jms_conn = factory.CreateConnection();
                Console.WriteLine("Created a connection!");
                _jms_session = _jms_conn.CreateSession();
                Console.WriteLine("Session started!");

 public void Subscribe(string queue, bool enable_async_receive)
                IDestination destination = _jms_session.GetQueue(queue);
                Console.WriteLine("Using destination: " + destination);

                // lets create a consumer and producer
                _consumer = _jms_session.CreateConsumer(destination);
                if (enable_async_receive)
                    _consumer.Listener += new
                _producer = _jms_session.CreateProducer(destination);
                _producer.Persistent = false;

 void _consumer_Listener(IMessage message)
                lock (this)

  public string Receive()
                IMessage message = _consumer.Receive();
                if (message == null)
                    return null;
                    return ((ITextMessage) message).Text;

By trial and error I found out if I call the Receive() method above I seem
to unclog the queue and my event listener kicks back in. Any idea why this

P.S.: The provided example java consumer doesn't seem to have any problem
getting messages from the queue because I think it also just calls Receive()
a number of times and doesn't use a listener.

View this message in context:
Sent from the ActiveMQ - User forum at

View raw message