[libanyevent-rabbitmq-perl] 96/151: Allow multiple RMQ connections in the same process

Damyan Ivanov dmn at moszumanska.debian.org
Thu Jan 16 11:03:07 UTC 2014


This is an automated email from the git hooks/post-receive script.

dmn pushed a commit to annotated tag debian/1.12-1
in repository libanyevent-rabbitmq-perl.

commit d0d0f2e7d6e6aa20b0e822984b5a332d7e27c1eb
Author: Tomas Doran <bobtfish at bobtfish.net>
Date:   Tue Jul 26 11:27:03 2011 +0100

    Allow multiple RMQ connections in the same process
---
 Changes                  |  3 +++
 lib/AnyEvent/RabbitMQ.pm | 13 +++++++++----
 2 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/Changes b/Changes
index c3e8af7..6ec4a3b 100644
--- a/Changes
+++ b/Changes
@@ -1,5 +1,8 @@
 Revision history for Perl extension AnyEvent::RabbitMQ
 
+        - Allow multiple clients to have independent connections
+          to RabbitMQ, as long as they all use the same spec file.
+
 1.05    Tue Jul 22 16:55:55 2011
         - Fixed a compiling error.
 
diff --git a/lib/AnyEvent/RabbitMQ.pm b/lib/AnyEvent/RabbitMQ.pm
index 5e3c098..b00e421 100644
--- a/lib/AnyEvent/RabbitMQ.pm
+++ b/lib/AnyEvent/RabbitMQ.pm
@@ -4,7 +4,7 @@ use strict;
 use warnings;
 
 use Data::Dumper;
-use Carp qw(confess);
+use Carp qw(confess croak);
 use List::MoreUtils qw(none);
 use Devel::GlobalDestruction;
 use namespace::clean;
@@ -54,12 +54,17 @@ sub login_user {
     return $self->{_login_user};
 }
 
+my $_loaded_spec;
 sub load_xml_spec {
     my $self = shift;
     my ($spec) = @_;
-    Net::AMQP::Protocol->load_xml_spec(
-        $spec || $DEFAULT_AMQP_SPEC
-    ); # die when fail in this line.
+    $spec ||= $DEFAULT_AMQP_SPEC;
+    if ($_loaded_spec && $_loaded_spec ne $spec) {
+        croak("Tried to load AMQP spec $spec, but have already loaded $_loaded_spec, not possible");
+    }
+    elsif (!$_loaded_spec) {
+        Net::AMQP::Protocol->load_xml_spec($_loaded_spec = $spec);
+    }
     return $self;
 }
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/libanyevent-rabbitmq-perl.git



More information about the Pkg-perl-cvs-commits mailing list