[libanyevent-rabbitmq-perl] 03/151: Added method for qos and recover.
Damyan Ivanov
dmn at moszumanska.debian.org
Thu Jan 16 11:02:59 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 3d66412d9872918c0fb21520bf05299a94e210f6
Author: cooldaemon <cooldaemon at gmail.com>
Date: Sat Dec 12 01:32:30 2009 +0900
Added method for qos and recover.
---
lib/RabbitFoot.pm | 33 ++++++++++++++++++++++++++++++++-
xt/04_use_server.t | 44 +++++++++++++++++++++++++++++++++++++++++++-
2 files changed, 75 insertions(+), 2 deletions(-)
diff --git a/lib/RabbitFoot.pm b/lib/RabbitFoot.pm
index 1ea3597..2ffe395 100644
--- a/lib/RabbitFoot.pm
+++ b/lib/RabbitFoot.pm
@@ -490,6 +490,36 @@ sub ack {
),
1,
);
+ return;
+}
+
+sub qos {
+ my ($self, $args,) = @_;
+
+ return $self->_post_and_read(
+ 'Basic::Qos',
+ {
+ prefetch_count => 1,
+ %$args,
+ prefetch_size => 0,
+ global => 0,
+ },
+ 'Basic::QosOk',
+ 1,
+ );
+}
+
+sub recover {
+ my ($self, $args,) = @_;
+
+ $self->_post(
+ Net::AMQP::Protocol::Basic::Recover->new(
+ requeue => 0,
+ %$args,
+ ),
+ 1,
+ );
+ return;
}
sub _post_and_read {
@@ -681,7 +711,8 @@ You can use RabbitFoot to -
* Declare and delete exchanges
* Declare, delete and bind queues
- * Publish, consume, get and ack messages
+ * Set QoS
+ * Publish, consume, get, ack and recover messages
RabbitFoot is known to work with RabbitMQ versions 1.7.0 and version 0-8 of the AMQP specification.
diff --git a/xt/04_use_server.t b/xt/04_use_server.t
index cf9d5f5..74cfa1d 100644
--- a/xt/04_use_server.t
+++ b/xt/04_use_server.t
@@ -21,7 +21,7 @@ eval {
plan skip_all => 'Connection failure: '
. $conf->{host} . ':' . $conf->{port} if $@;
-plan tests => 17;
+plan tests => 19;
use RabbitFoot;
@@ -101,6 +101,48 @@ lives_ok sub {
}, 'ack get';
lives_ok sub {
+ publish($rf, 'RabbitMQ is excellent.');
+ publish($rf, 'RabbitMQ is fantastic.');
+ $rf->qos({prefetch_count => 2});
+
+ $rf->consume({
+ queue => 'test_q',
+ no_ack => 0,
+ });
+
+ my @responses = map {$rf->poll({timeout => 1})} (1, 2);
+ for my $response (@responses) {
+ $rf->ack({
+ delivery_tag => $response->{deliver}->method_frame->delivery_tag,
+ });
+ }
+
+ $rf->cancel();
+ $rf->qos({});
+}, 'qos';
+
+lives_ok sub {
+ publish($rf, 'RabbitMQ is powerful.');
+
+ $rf->consume({
+ queue => 'test_q',
+ no_ack => 0,
+ });
+
+ for (1..5) {
+ my $response = $rf->poll({timeout => 1});
+ $rf->recover({});
+ }
+
+ my $response = $rf->poll({timeout => 1});
+ $rf->ack({
+ delivery_tag => $response->{deliver}->method_frame->delivery_tag,
+ });
+
+ $rf->cancel();
+}, 'recover';
+
+lives_ok sub {
$rf->purge_queue({queue => 'test_q'});
}, 'purge_queue';
--
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