[rabbitmq-discuss] Queuing fundamentals.
Pieter de Zwart
pdezwart at rubiconproject.com
Mon Oct 10 18:02:20 BST 2011
I am trying to modify the behavior of the php-amqp consume method to be
more accurate. The consume method allows for the setting of a minimum and
maximum number of desired messages. The "correct" (and optimal) behavior
would therefore be to set the prefetch count to the max messages value. I
would gladly do this, except I don’t know how. We are using:
amqp_basic_consume(cnn->conn, AMQP_CHANNEL, amqp_cstring_bytes(ctx->name),
AMQP_EMPTY_BYTES, 0, 0, 0, AMQP_EMPTY_TABLE);
To get data out of the queue. Is this a parameter I should be passing into
amqp_basic_consume, or do I need to do some other tomfoolery to make this
work?
I looked through the examples but found nothing =(
Thanks!
me
On 8/3/11 5:08 PM, "Pieter de Zwart" <pdezwart at rubiconproject.com> wrote:
>I don¹t actually think we support pre-fetch. If it is in the rabbitmq-c
>library, then we can support it relatively easily. Andrew, can you please
>file a bug and I will see if we can address this quickly.
>me
>
>
>
>
>
>
>
>On 8/2/11 2:04 AM, "Eugene Kirpichov" <ekirpichov at gmail.com> wrote:
>
>>Hi,
>>
>>I'm not sure how to set the prefetch size with the PHP library, and I
>>don't know whether the 'min' and 'max' parameters are related to it.
>>I believe that in theory, your scenario should work as you wished, if
>>you set prefetch to 1. It did for me at least, with the .NET client.
>>
>>2011/8/1 Andrew <aph at repido.co.uk>:
>>> Hi Eugene ,
>>>
>>> My code is written in PHP and is using the PHP AMQP library (http://
>>> www.php.net/manual/en/book.amqp.php) and in my calls to the consume()
>>> method I am setting parameters that specify a minimum delivery of zero
>>> messages and a maximum of one. This I had hoped would just get one
>>> message from the queue at a time for me to process.
>>>
>>> Certainly what you suggest would explain the behaviour so perhaps my
>>> understanding of the parameters to the consume() method is wrong.
>>>
>>> Do you think that what I am trying to achieve should in theory work?
>>> If so, what should happen to message 3 after it's failed ACK? i.e.
>>> should my next request to the queue retrieve it, or will it always be
>>> delivered out of sequence after a failed ACK? If the latter is the
>>> case, how do I achieve ordered delivery of my messages even when my
>>> consume process dies and restarts?
>>>
>>> Thanks,
>>> Andrew
>>>
>>> On Aug 1, 5:41 pm, Eugene Kirpichov <ekirpic... at gmail.com> wrote:
>>>> I suppose that you haven't set the prefetch count to 1.
>>>>
>>>> So in fact you had messages 3,4,5,6 all delivered to you (so thought
>>>> the broker) and when the consumer died, the broker requeued all of
>>>> them in no particular sequence.
>>>>
>>>> 2011/8/1 Andrew <a... at repido.co.uk>:
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> > Hi everybody,
>>>>
>>>> > I wondered if somebody might be able to clarify some behaviour for
>>>>me
>>>> > as I am getting confused about whether the scenario I am
>>>>experiencing
>>>> > is due to a lack of understanding of how RabbitMQ works or something
>>>> > else.
>>>>
>>>> > I have one reader process which may die due to system failure and at
>>>> > restart I'd like the same single consumer process to start up again
>>>> > and pick up where it left off. So a summary of what I'd like to
>>>>happen
>>>> > is:
>>>>
>>>> > (1) My transmitter process sends and queues up messages 1, 2, 3, 4,
>>>>5
>>>> > & 6.
>>>> > (2) My single consumer process reads and acknowledges messages 1 and
>>>>2
>>>> > in sequence.
>>>> > (3) My consumer process reads message 3 and then dies without
>>>> > acknowledging.
>>>> > (4) I restart my consumer process which will request the next
>>>>message,
>>>> > which should be the unacknowledged message (3).
>>>> > (5) My consumer process would then continue reading messages from
>>>>the
>>>> > queue (4, 5, & 6) in sequence.
>>>>
>>>> > What I am experiencing is that when my consumer process is restarted
>>>> > messages 3, 4, 5 & 6 are delivered out of sequence and all with a
>>>> > redelivery count of 1. I understand that message 3 might be out of
>>>> > sequence because it was unacknowledged and from what I have read,
>>>>when
>>>> > a message is redelivered then it's sequence is no longer guaranteed.
>>>> > However I'm not clear as to why the remaining queued messages are
>>>>out
>>>> > of sequence too.
>>>>
>>>> > More importantly is what I am trying to do is something that is
>>>> > contrary to how RabbitMQ works, or am I just going about it the
>>>>wrong
>>>> > way?
>>>>
>>>> > Many thanks for your help,
>>>> > Andrew
>>>>
>>>> > _______________________________________________
>>>> > rabbitmq-discuss mailing list
>>>> > rabbitmq-disc... at lists.rabbitmq.com
>>>> >https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss
>>>>
>>>> --
>>>> Eugene Kirpichov
>>>> Principal Engineer, Mirantis Inc.http://www.mirantis.com/
>>>> Editor,http://fprog.ru/
>>>> _______________________________________________
>>>> rabbitmq-discuss mailing list
>>>>
>>>>rabbitmq-disc... at lists.rabbitmq.comhttps://lists.rabbitmq.com/cgi-bin/m
>>>>a
>>>>ilman/listinfo/rabbitmq-discuss
>>> _______________________________________________
>>> rabbitmq-discuss mailing list
>>> rabbitmq-discuss at lists.rabbitmq.com
>>> https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss
>>>
>>
>>
>>
>>--
>>Eugene Kirpichov
>>Principal Engineer, Mirantis Inc. http://www.mirantis.com/
>>Editor, http://fprog.ru/
>>_______________________________________________
>>rabbitmq-discuss mailing list
>>rabbitmq-discuss at lists.rabbitmq.com
>>https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss
>
>_______________________________________________
>rabbitmq-discuss mailing list
>rabbitmq-discuss at lists.rabbitmq.com
>https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss
More information about the rabbitmq-discuss
mailing list