[rabbitmq-discuss] Channel.Close w/ subscribed consumers
Aman Gupta
rabbitmq at tmm1.net
Tue Dec 1 09:04:08 GMT 2009
On Tue, Dec 1, 2009 at 2:38 AM, Matthias Radestock <matthias at lshift.net> wrote:
> Aman,
>
> Matthias Radestock wrote:
>>
>> I'm not sure when I will find time to look into this.
>
> Have done so now. I cannot reproduce the problem.
>
> With two terminals, one running 'ruby subscriber.rb' and the other running
> 'ruby publisher.rb', I can ^C the subscriber and the program terminates
> almost instantly.
>
> I have tried this with both ruby 1.8 and 1.9.1, and versions 0.6.5 of the
> amqp gem and 0-12.10 of em, all running against the head of 'default' of the
> rabbitmq-server.
Thanks for taking the time to test this. I tried on linux with R12 and
R13 and you're right, it stops almost instantaneously. On my mac, it
takes a bit longer but still stops within 5-10 seconds.
The original bug report came with the 'sleep 1' which was commented
out in my version of subscriber.rb. The sleep exposes the issue, but
some digging shows the cause to be EventMachine and not rabbitmq.
The problem is that EM reads up to 16k from the socket during each
reactor tick. This can account for several hundred messages, each of
which is passed to the subscribe block. If each message causes a
sleep(1), the reactor is essentially blocked for several seconds. Once
all 16k worth of messages are processed, the reactor finally has a
chance to flush its outbound buffers, which contain the Channel.Close
command.
The solution to this problem is to set a prefetch window on the
channel, such that the reactor is not flooded with incoming messages.
Aman
>
>
> Regards,
>
> Matthias.
>
More information about the rabbitmq-discuss
mailing list