Possible bug in Priority Queue plugin

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Possible bug in Priority Queue plugin

Steven Blanc

I have been experimenting with the priority queue plugin (3.3.x-72d20292) with RMQ Server 3.3.2.

 

I have a simple producer and a simple consumer written in C++ using SimplelAmqpClient.

 

The consumer app creates  a Channel (SimpleAmpqClient Channel), the exchange, the queue (as a priority queue with x-max-priority of 10) and a binding.

I see this all properly from the RMW Admin GUI.

After that it calls BasicConsume() and then goes into a loop calling BasicConsumeMessage() with a 1 second sleep between calls.

 

Meanwhile, the simple producer creates a broker connection, then goes into a loop creating messages with a priority value assigned to be either 0 or 10.

 

Where I think I see a bug is this:

If the consumer calls BasicConsume BEFORE the messages are in the queue, they are consumed in FIFO order, without consideration of the priority value.

If I sleep in the consumer before calling BasicConsume() until all messages are in the queue, they are consumed in priority order.

 

Am I doing something wrong?  Shouldn't the priority on each message place it in the queue according to priority over time and the already connected consumer(s) will get higher priority messages ahead of lower priority messages all the time?

 

I looked at the Java example provided here:

https://github.com/rabbitmq/rabbitmq-priority-queue/blob/master/examples/java/src/com/rabbitmq/examples/PriorityQueue.java

I am not a Java programmer, but it appears that example also publishes messages to a priority queue before there is a consumer and then creates a consumer of the queue which retrieves messages in priority order.  Same results I see, but not the desired behavior I am looking for.

 

Should this work after a consumer is attached to a queue and consuming it for all subsequent messages?

 

Thanks,

Steve


_______________________________________________
rabbitmq-discuss mailing list has moved to https://groups.google.com/forum/#!forum/rabbitmq-users,
please subscribe to the new list!

[hidden email]
https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss
Reply | Threaded
Open this post in threaded view
|

Re: Possible bug in Priority Queue plugin

Simon MacMullen-2
I don't know SimpleAmqpClient but from your description it sounds like
you are consuming with no prefetch limit - i.e. RabbitMQ will send your
consumer as many messages as it likes, limited only by network speed.

Therefore messages aren't resting in the queue at all, they're sent
straight out to the client, and there is no opportunity for higher
priority messages to overtake lower ones.

You need to make sure messages are backing up in the queue (e.g. by
consuming with basic.qos set to some small value like 1) to see the
prioritising effect.

Cheers, Simon

On 08/07/2014 10:09PM, Steven Blanc wrote:

> I have been experimenting with the priority queue plugin
> (3.3.x-72d20292) with RMQ Server 3.3.2.
>
> I have a simple producer and a simple consumer written in C++ using
> SimplelAmqpClient.
>
> The consumer app creates  a Channel (SimpleAmpqClient Channel), the
> exchange, the queue (as a priority queue with x-max-priority of 10) and
> a binding.
>
> I see this all properly from the RMW Admin GUI.
>
> After that it calls BasicConsume() and then goes into a loop calling
> BasicConsumeMessage() with a 1 second sleep between calls.
>
> Meanwhile, the simple producer creates a broker connection, then goes
> into a loop creating messages with a priority value assigned to be
> either 0 or 10.
>
> Where I think I see a bug is this:
>
> If the consumer calls BasicConsume BEFORE the messages are in the queue,
> they are consumed in FIFO order, without consideration of the priority
> value.
>
> If I sleep in the consumer before calling BasicConsume() until all
> messages are in the queue, they are consumed in priority order.
>
> Am I doing something wrong?  Shouldn't the priority on each message
> place it in the queue according to priority over time and the already
> connected consumer(s) will get higher priority messages ahead of lower
> priority messages all the time?
>
> I looked at the Java example provided here:
>
> https://github.com/rabbitmq/rabbitmq-priority-queue/blob/master/examples/java/src/com/rabbitmq/examples/PriorityQueue.java
>
> I am not a Java programmer, but it appears that example also publishes
> messages to a priority queue before there is a consumer and then creates
> a consumer of the queue which retrieves messages in priority order.
> Same results I see, but not the desired behavior I am looking for.
>
> Should this work after a consumer is attached to a queue and consuming
> it for all subsequent messages?
>
> Thanks,
>
> Steve
>
>
>
> _______________________________________________
> rabbitmq-discuss mailing list has moved to https://groups.google.com/forum/#!forum/rabbitmq-users,
> please subscribe to the new list!
>
> [hidden email]
> https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss
>

--
Simon MacMullen
RabbitMQ, Pivotal
_______________________________________________
rabbitmq-discuss mailing list has moved to https://groups.google.com/forum/#!forum/rabbitmq-users,
please subscribe to the new list!

[hidden email]
https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss
Reply | Threaded
Open this post in threaded view
|

Re: Possible bug in Priority Queue plugin

Steven Blanc
Simon,
Thank you.  As always, you guys have the answers.

I am making sure messages back up in the queue by producing with no
delay and consuming with a 1 second delay between calls to BasicConumeMessage.

Once I set the prefetch count to 1 and properly ACK'd all the messages
the behavior was as expected/desired.

Steve

-----Original Message-----
From: Simon MacMullen [mailto:[hidden email]]
Sent: Wednesday, July 09, 2014 5:10 AM
To: Legacy list about RabbitMQ; Steven Blanc
Subject: Re: [rabbitmq-discuss] Possible bug in Priority Queue plugin

I don't know SimpleAmqpClient but from your description it sounds like
you are consuming with no prefetch limit - i.e. RabbitMQ will send your
consumer as many messages as it likes, limited only by network speed.

Therefore messages aren't resting in the queue at all, they're sent
straight out to the client, and there is no opportunity for higher
priority messages to overtake lower ones.

You need to make sure messages are backing up in the queue (e.g. by
consuming with basic.qos set to some small value like 1) to see the
prioritising effect.

Cheers, Simon

On 08/07/2014 10:09PM, Steven Blanc wrote:

> I have been experimenting with the priority queue plugin
> (3.3.x-72d20292) with RMQ Server 3.3.2.
>
> I have a simple producer and a simple consumer written in C++ using
> SimplelAmqpClient.
>
> The consumer app creates  a Channel (SimpleAmpqClient Channel), the
> exchange, the queue (as a priority queue with x-max-priority of 10) and
> a binding.
>
> I see this all properly from the RMW Admin GUI.
>
> After that it calls BasicConsume() and then goes into a loop calling
> BasicConsumeMessage() with a 1 second sleep between calls.
>
> Meanwhile, the simple producer creates a broker connection, then goes
> into a loop creating messages with a priority value assigned to be
> either 0 or 10.
>
> Where I think I see a bug is this:
>
> If the consumer calls BasicConsume BEFORE the messages are in the queue,
> they are consumed in FIFO order, without consideration of the priority
> value.
>
> If I sleep in the consumer before calling BasicConsume() until all
> messages are in the queue, they are consumed in priority order.
>
> Am I doing something wrong?  Shouldn't the priority on each message
> place it in the queue according to priority over time and the already
> connected consumer(s) will get higher priority messages ahead of lower
> priority messages all the time?
>
> I looked at the Java example provided here:
>
> https://github.com/rabbitmq/rabbitmq-priority-queue/blob/master/examples/java/src/com/rabbitmq/examples/PriorityQueue.java
>
> I am not a Java programmer, but it appears that example also publishes
> messages to a priority queue before there is a consumer and then creates
> a consumer of the queue which retrieves messages in priority order.
> Same results I see, but not the desired behavior I am looking for.
>
> Should this work after a consumer is attached to a queue and consuming
> it for all subsequent messages?
>
> Thanks,
>
> Steve
>
>
>
> _______________________________________________
> rabbitmq-discuss mailing list has moved to https://groups.google.com/forum/#!forum/rabbitmq-users,
> please subscribe to the new list!
>
> [hidden email]
> https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss
>

--
Simon MacMullen
RabbitMQ, Pivotal
_______________________________________________
rabbitmq-discuss mailing list has moved to https://groups.google.com/forum/#!forum/rabbitmq-users,
please subscribe to the new list!

[hidden email]
https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss
Reply | Threaded
Open this post in threaded view
|

Re: Possible bug in Priority Queue plugin

Michael Klishin-2
 On 9 July 2014 at 16:03:16, Steven Blanc ([hidden email]) wrote:
> > I am making sure messages back up in the queue by producing with  
> no
> delay and consuming with a 1 second delay between calls to BasicConumeMessage.  

Just to clarify: do you mean basic.get? basic.consume creates a "push" subscription (RabbitMQ will
push messages to the client), so it doesn't need to be run multiple times.
--  
MK  

Staff Software Engineer, Pivotal/RabbitMQ
_______________________________________________
rabbitmq-discuss mailing list has moved to https://groups.google.com/forum/#!forum/rabbitmq-users,
please subscribe to the new list!

[hidden email]
https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss
Reply | Threaded
Open this post in threaded view
|

Re: Possible bug in Priority Queue plugin

Steven Blanc
Hi Michael,

Nope, I did mean BasicConsume/BasicConsumeMessage.  
I could have done this with BasicGet but I used BasicConsume followed by a looping BasicConsumeMessage.  In SimpleAmqpClient BasicConsumeMessage will wait for a message from the broker, where BasicGet will simply return false if no message is present.

Here is the gist of my consumer.  The producer has no sleep and will pile up its messages (with BasicPublish) much quicker than this is supposed to consume them, thus allowing messages with low priority to build up for the occasional high priority message to arrive and be inserted above them.

    channel->BasicConsume(queue_name, consumerTag, true, false, false, /*prefetch*/1);

    for(int i = 0; i < repetitions; i++)
    {
        Envelope::ptr_t myEnvelope = channel->BasicConsumeMessage(consumerTag);
          BasicMessage::ptr_t msg_out = myEnvelope->Message();

        // ACK the message
        channel->BasicAck(myEnvelope);        

        sleep(1);
    }


-----Original Message-----
From: Michael Klishin [mailto:[hidden email]]
Sent: Wednesday, July 09, 2014 8:07 AM
To: Steven Blanc; Legacy list about RabbitMQ
Subject: Re: [rabbitmq-discuss] Possible bug in Priority Queue plugin

 On 9 July 2014 at 16:03:16, Steven Blanc ([hidden email]) wrote:
> > I am making sure messages back up in the queue by producing with  
> no
> delay and consuming with a 1 second delay between calls to BasicConumeMessage.  

Just to clarify: do you mean basic.get? basic.consume creates a "push" subscription (RabbitMQ will
push messages to the client), so it doesn't need to be run multiple times.
--  
MK  

Staff Software Engineer, Pivotal/RabbitMQ
_______________________________________________
rabbitmq-discuss mailing list has moved to https://groups.google.com/forum/#!forum/rabbitmq-users,
please subscribe to the new list!

[hidden email]
https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss