Skip Menu |

This queue is for tickets about the AnyEvent-RabbitMQ CPAN distribution.

Report information
The Basics
Id: 69408
Status: resolved
Priority: 0/
Queue: AnyEvent-RabbitMQ

People
Owner: Nobody in particular
Requestors: develop [...] traveljury.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Closing a channel with multiple consuming queues causes an error
Hiya If I am consuming multiple queues with one channel, and I try to close that channel, it tries to cancel the queues first, but each on_success callback then tries to close the channel -> error. here's a patch: --- AnyEvent/RabbitMQ/Channel.pm 2011-07-11 20:52:21.886343198 +0200 +++ AnyEvent/RabbitMQ/Channel.pm.new 2011-07-11 20:52:15.079059124 +0200 @@ -59,16 +59,19 @@ return $self if !$self->{_is_open}; - return $self->_close(%args) if 0 == scalar keys %{$self->{_consumer_cbs}}; + my %cbs = %{$self->{_consumer_cbs}}; + return $self->_close(%args) unless %cbs; - for my $consumer_tag (keys %{$self->{_consumer_cbs}}) { + for my $consumer_tag (keys %cbs) { $self->cancel( consumer_tag => $consumer_tag, on_success => sub { - $self->_close(%args); + delete $cbs{$consumer_tag}; + $self->_close(%args) unless %cbs; }, on_failure => sub { - $self->_close(%args); + delete $cbs{$consumer_tag}; + $self->_close(%args) unless %cbs; $args{on_failure}->(@_); } );
Uploaded the patch as a separate file
Subject: multi_consumers.patch
--- AnyEvent/RabbitMQ/Channel.pm 2011-07-11 20:52:21.886343198 +0200 +++ AnyEvent/RabbitMQ/Channel.pm.new 2011-07-11 20:52:15.079059124 +0200 @@ -59,16 +59,19 @@ return $self if !$self->{_is_open}; - return $self->_close(%args) if 0 == scalar keys %{$self->{_consumer_cbs}}; + my %cbs = %{$self->{_consumer_cbs}}; + return $self->_close(%args) unless %cbs; - for my $consumer_tag (keys %{$self->{_consumer_cbs}}) { + for my $consumer_tag (keys %cbs) { $self->cancel( consumer_tag => $consumer_tag, on_success => sub { - $self->_close(%args); + delete $cbs{$consumer_tag}; + $self->_close(%args) unless %cbs; }, on_failure => sub { - $self->_close(%args); + delete $cbs{$consumer_tag}; + $self->_close(%args) unless %cbs; $args{on_failure}->(@_); } );
From: chip [...] pobox.com
I have a more complete solution that also ensures that when a channel closes, any requests pending on that channel are informed and their on_failure callbacks are called. This is especially important when using Net::RabbitFoot on top of this module. See https://github.com/chipdude/AnyEvent-RabbitMQ
This issue has been fixed in the latest release.