Hi Pieter,

Pieter de Zwart <pdezwart at rubiconproject.com> writes:
I am doing something wrong, and I could use some help. I
maintain/develop the PHP extension that interfaces with RabbitMQ via
the rabbitmq-c library. We have implemented all of the low level
calls, but have also added some helpful wrappers to let poor PHP users
not have to deal with all the complexity of the protocol. One of these
wrapper methods is AMQPQueue::getMessages(). Unfortunately, I have
built a bug I don?t know how to squash.

During the second call to the AMQPQueue::getMessages() function within
a loop (reusing connection and channel), the process get stuck in busy
wait. In the attached file on line 37, we call amqp_basic_qos() to
prevent any prefetching by the server. That call goes through the
following stack in rabbitmq-c:

librabbitmq/amqp_framing.c:1999: amqp_basic_qos
librabbitmq/amqp_socket.c:356: amqp_simple_rpc_decoded
librabbitmq/amqp_socket.c:264: amqp_simple_rpc
librabbitmq/amqp_socket.c:157: wait_frame_inner

And then it gets stuck in that while(1) loop.
Nothing stands out as being obviously wrong in your code (I do notice
one issue, but it is not responsible for the problem you describe).

If you think you can guide a PHP newbie through how to trigger the
problem within PHP, I'd be happy to try.

Here is the issue I mentioned:
/* Set the QOS for this channel to match the max_messages */
amqp_basic_qos(
connection->connection_resource->connection_state,
channel->channel_id,
0, /* prefetch window size */
0, /* prefetch message count */
0 /* global flag */
);
The AMQP terminology here is a bit confusing. Setting the prefetch
count to 0 does not mean "no prefetch". The prefetch count represents a
limit on the number of unacked messages for the channel/connection.
Actually setting it to zero wouldn't make sense, as the server would not
be able to deliver any messages to the client. So a prefetch count of
zero is specified to mean "no limit".

Instead, you should set the prefetch count to one, meaning "allow me to
have one unacked message, but no more". In other words, no messages are
prefetched.

The prefetch size should be left as zero, because you don't want to
limit that.

David

--
David Wragg
Staff Engineer, RabbitMQ
VMware, Inc.

Search Discussions

Discussion Posts

Previous

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 2 of 10 | next ›
Discussion Overview
grouprabbitmq-discuss @
categoriesrabbitmq
postedNov 8, '11 at 2:35a
activeNov 10, '11 at 12:34a
posts10
users3
websiterabbitmq.com
irc#rabbitmq

People

Translate

site design / logo © 2022 Grokbase