You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by sparky2708 <da...@columbia.edu> on 2006/08/04 17:33:43 UTC

Queue gets clogged in OpenWire.NET when using Listener

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
Uri(url));
                _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
MessageListener(_consumer_Listener);
                
                _producer = _jms_session.CreateProducer(destination);
                _producer.Persistent = false;
            }


 void _consumer_Listener(IMessage message)
            {
                lock (this)
                {
                    OnMessageReceived(((ITextMessage)message).Text);
                }
            }

  public string Receive()
            {
                IMessage message = _consumer.Receive();
                if (message == null)
                    return null;
                else
                    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
happens?

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: http://www.nabble.com/Queue-gets-clogged-in-OpenWire.NET-when-using-Listener-tf2051829.html#a5652526
Sent from the ActiveMQ - User forum at Nabble.com.


Re: PLEASE ADD BUG: Queue gets clogged in OpenWire.NET when using Listener

Posted by sparky2708 <da...@columbia.edu>.
Will try it out next week and will definitely let you know! Thank you very
much!


James.Strachan wrote:
> 
> This issue is now resolved in SVN trunk if you want to try it out
> 
> On 8/7/06, sparky2708 <da...@columbia.edu> wrote:
>>
>> added to JIRA
>> --
>> View this message in context:
>> http://www.nabble.com/Queue-gets-clogged-in-OpenWire.NET-when-using-Listener-tf2051829.html#a5687762
>> Sent from the ActiveMQ - User forum at Nabble.com.
>>
>>
> 
> 
> -- 
> 
> James
> -------
> http://radio.weblogs.com/0112098/
> 
> 

-- 
View this message in context: http://www.nabble.com/Queue-gets-clogged-in-OpenWire.NET-when-using-Listener-tf2051829.html#a5860758
Sent from the ActiveMQ - User forum at Nabble.com.


Re: PLEASE ADD BUG: Queue gets clogged in OpenWire.NET when using Listener

Posted by James Strachan <ja...@gmail.com>.
This issue is now resolved in SVN trunk if you want to try it out

On 8/7/06, sparky2708 <da...@columbia.edu> wrote:
>
> added to JIRA
> --
> View this message in context: http://www.nabble.com/Queue-gets-clogged-in-OpenWire.NET-when-using-Listener-tf2051829.html#a5687762
> Sent from the ActiveMQ - User forum at Nabble.com.
>
>


-- 

James
-------
http://radio.weblogs.com/0112098/

Re: PLEASE ADD BUG: Queue gets clogged in OpenWire.NET when using Listener

Posted by sparky2708 <da...@columbia.edu>.
added to JIRA
-- 
View this message in context: http://www.nabble.com/Queue-gets-clogged-in-OpenWire.NET-when-using-Listener-tf2051829.html#a5687762
Sent from the ActiveMQ - User forum at Nabble.com.


Re: PLEASE ADD BUG: Queue gets clogged in OpenWire.NET when using Listener

Posted by sparky2708 <da...@columbia.edu>.
Switched to using Topics and this bug seems gone. Is there something
fundamentally different between Topics and Queue that is creating this
behavior? Maybe I am unaware of some nuance?
-- 
View this message in context: http://www.nabble.com/Queue-gets-clogged-in-OpenWire.NET-when-using-Listener-tf2051829.html#a5685915
Sent from the ActiveMQ - User forum at Nabble.com.


Re: PLEASE ADD BUG: Queue gets clogged in OpenWire.NET when using Listener

Posted by sparky2708 <da...@columbia.edu>.
I thought of a hack for this problem (see my code above for original code).
It's not great but it kicks in the listener and doesn't lose messages:

 // lets create a consumer and producer
 IMessageConsumer consumer = session.CreateConsumer(destination); 
 consumer.Listener += new MessageListener(consumer_Listener); 
 _consumer_Listener(_consumer.ReceiveNoWait());
-- 
View this message in context: http://www.nabble.com/Queue-gets-clogged-in-OpenWire.NET-when-using-Listener-tf2051829.html#a5685151
Sent from the ActiveMQ - User forum at Nabble.com.


Re: PLEASE ADD BUG: Queue gets clogged in OpenWire.NET when using Listener

Posted by sparky2708 <da...@columbia.edu>.
Hi, 
I was also wondering what you think might be a possible timeframe for a fix
for this sort of an issue. As I am still evaluating ActiveMQ for suitability
for our organization I believe my project manager would consider this a
show-stopper bug as we have a lot of tools in C#. We are overall pleased
with our testing of ActiveMQ and would really like to see this work so
please confirm the bug (maybe I am doing something wrong in my code?)
-- 
View this message in context: http://www.nabble.com/Queue-gets-clogged-in-OpenWire.NET-when-using-Listener-tf2051829.html#a5684833
Sent from the ActiveMQ - User forum at Nabble.com.


PLEASE ADD BUG: Queue gets clogged in OpenWire.NET when using Listener

Posted by sparky2708 <da...@columbia.edu>.
Updated the client just now. This seems like a confirmed bug in OpenWire.NET
but I can't figure out how to submit this using your bug tracking software.
Please submit this for me. Easiest way to reproduce the bug would be to
start the consumer using the following code and then AFTER the consumer
starts, start some producer (either java or C#) and you will notice that the
consumer will not get any messages (seems like calling Receive() on the
consumer at least once will make you lose a message but the listener will
kick back in):

using System;
using ActiveMQ;
using ActiveMQ.Commands;
using NMS;

namespace JMSClient
{
    /// <summary>
    /// Summary description for Class1.
    /// </summary>
    class Class1
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main(string[] args)
        {
            IConnectionFactory factory = new ConnectionFactory(new
Uri("tcp://localhost:61616?jms.useAsyncSend=true"));
            using (IConnection connection = factory.CreateConnection())
            {
                Console.WriteLine("Created a connection!");

                ISession session = connection.CreateSession();
                IDestination destination =
session.GetQueue("EXCEL.TESTQUEUE");
                Console.WriteLine("Using destination: " + destination);

                // lets create a consumer and producer
                IMessageConsumer consumer =
session.CreateConsumer(destination);
                consumer.Listener += new MessageListener(consumer_Listener);

                while (true);
            }
        }

        static void consumer_Listener(IMessage message)
        {
            if (message == null)
            {
                Console.WriteLine("No message received!");
            }
            else
            { 
                Console.WriteLine("Received message with text: " +
((ActiveMQTextMessage)message).Text);
            }
         }
    }
}



-- 
View this message in context: http://www.nabble.com/Queue-gets-clogged-in-OpenWire.NET-when-using-Listener-tf2051829.html#a5684650
Sent from the ActiveMQ - User forum at Nabble.com.


Re: Queue gets clogged in OpenWire.NET when using Listener

Posted by sparky2708 <da...@columbia.edu>.
I will update the client on Monday and see if that fixes the problem. I don't
expect any difference unless this change was made in the last 2 weeks as
this is how old my revision is.
-- 
View this message in context: http://www.nabble.com/Queue-gets-clogged-in-OpenWire.NET-when-using-Listener-tf2051829.html#a5663562
Sent from the ActiveMQ - User forum at Nabble.com.


Re: Queue gets clogged in OpenWire.NET when using Listener

Posted by James Strachan <ja...@gmail.com>.
I wonder if this is some kind of acknowledgement bug in the
ActiveMQ.Net client. Incidentally are you using SVN trunk as I
remember patching some bug in this area recently.

If that doesn't fix it please raise a JIRA so we can track the issue

On 8/4/06, sparky2708 <da...@columbia.edu> wrote:
>
> 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
> Uri(url));
>                 _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
> MessageListener(_consumer_Listener);
>
>                 _producer = _jms_session.CreateProducer(destination);
>                 _producer.Persistent = false;
>             }
>
>
>  void _consumer_Listener(IMessage message)
>             {
>                 lock (this)
>                 {
>                     OnMessageReceived(((ITextMessage)message).Text);
>                 }
>             }
>
>   public string Receive()
>             {
>                 IMessage message = _consumer.Receive();
>                 if (message == null)
>                     return null;
>                 else
>                     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
> happens?
>
> 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: http://www.nabble.com/Queue-gets-clogged-in-OpenWire.NET-when-using-Listener-tf2051829.html#a5652526
> Sent from the ActiveMQ - User forum at Nabble.com.
>
>


-- 

James
-------
http://radio.weblogs.com/0112098/

Re: Queue gets clogged in OpenWire.NET when using Listener

Posted by sparky2708 <da...@columbia.edu>.
The strangest part about this is that this seems to happen consistently when
I try to do 30,000 messages and the queue always freezes at 18,300 messages
and then needs to be unclogged by the Receive() call I mentioned above
-- 
View this message in context: http://www.nabble.com/Queue-gets-clogged-in-OpenWire.NET-when-using-Listener-tf2051829.html#a5655132
Sent from the ActiveMQ - User forum at Nabble.com.