Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
MYMETA.*
cover_db
META.yml
Makefile
Expand Down
3 changes: 0 additions & 3 deletions Makefile.PL
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,16 @@ name 'Net-RabbitFoot';
all_from 'lib/Net/RabbitFoot.pm';

requires 'Moose';
requires 'MooseX::AttributeHelpers';
requires 'MooseX::App::Cmd';
requires 'MooseX::ConfigFromFile';
requires 'Config::Any';
requires 'JSON::XS';
requires 'List::MoreUtils';
requires 'AnyEvent::RabbitMQ' => '1.03';
requires 'Coro';
requires 'Coro::AnyEvent';

tests 't/*.t';
author_tests 'xt';
install_share;

build_requires 'Test::More';
build_requires 'Test::Exception';
Expand Down
23 changes: 21 additions & 2 deletions lib/Net/RabbitFoot.pm
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ Net::RabbitFoot - An Asynchronous and multi channel Perl AMQP client.
=head1 SYNOPSIS

use Net::RabbitFoot;
use Coro;

my $rf = Net::RabbitFoot->new()->load_xml_spec()->connect(
host => 'localhost',
Expand All @@ -85,9 +86,22 @@ Net::RabbitFoot - An Asynchronous and multi channel Perl AMQP client.
timeout => 1,
);

my $ch = $rf->open_channel();
my $ch = $rf->open_channel(on_return => sub { warn "message went nowhere: ".Dumper(shift) });
$ch->declare_exchange(exchange => 'test_exchange');

$ch->publish(...); # same params as AnyEvent::RabbitMQ

# confirm mode for 0.9
$ch->confirm;

my $returned;
$ch->publish(..., # normal publish params
mandatory => 1, # if it goes nowhere, return it
on_ack => rouse_cb,
on_return => sub { $returned = shift });
rouse_wait; # wait for ack
die "the message went nowhere" if $returned;

=head1 DESCRIPTION

Net::RabbitFoot is an AMQP(Advanced Message Queuing Protocol) client library, that is intended to allow you to interact with AMQP-compliant message brokers/servers such as RabbitMQ in an asynchronous fashion.
Expand All @@ -99,8 +113,13 @@ You can use Net::RabbitFoot to -
* Set QoS
* Publish, consume, get, ack and recover messages
* Select, commit and rollback transactions
* Set publish confirm mode and get callbacks on publish ack and return (AMQP 0.9)

Net::RabbitFoot is known to work with RabbitMQ versions 2.3.1 through 2.7.1 and versions 0-8 and 0-9-1 of the AMQP specification.

=head1 BUGS

Net::RabbitFoot is known to work with RabbitMQ versions 2.3.1 and version 0-8 of the AMQP specification.
Documentation would be nice.

=head1 AUTHOR

Expand Down
2 changes: 1 addition & 1 deletion lib/Net/RabbitFoot/Channel.pm
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ BEGIN {
close
declare_exchange delete_exchange
declare_queue bind_queue unbind_queue purge_queue delete_queue
consume cancel get qos
consume cancel get qos confirm
select_tx commit_tx rollback_tx
)) {
no strict 'refs';
Expand Down
12 changes: 8 additions & 4 deletions lib/Net/RabbitFoot/Cmd/Role/Command.pm
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use FindBin;
use Net::RabbitFoot;

use Moose::Role;
use Carp qw/ confess /;
requires qw(_run);

has spec => (
Expand Down Expand Up @@ -123,9 +124,10 @@ sub execute {
(map {$_ => $self->$_} qw(host port user pass vhost)),
timeout => 5,
on_close => sub {
my $reply = shift;
my $w; $w = AnyEvent->idle(cb => sub {
undef $w;
$self->_close(shift);
$self->_close($reply);
$rf_closed->send;
});
},
Expand All @@ -134,9 +136,10 @@ sub execute {
my $ch_closed = AnyEvent->condvar;
my $ch = $rf->open_channel(
on_close => sub {
my $reply = shift;
my $w; $w = AnyEvent->idle(cb => sub {
undef $w;
$self->_close(shift);
$self->_close($reply);
$ch_closed->send;
$rf->close;
});
Expand All @@ -153,8 +156,9 @@ sub execute {
}

sub _close {
my $self = shift;
my $method_frame = shift->method_frame;
my ($self, $reply) = @_;
confess "No reply" unless $reply;
my $method_frame = $reply->method_frame;
print $method_frame->reply_code, ' ', $method_frame->reply_text, "\n";
return;
}
Expand Down
Loading