AnyEvent::RabbitMQ::Fork - Run AnyEvent::RabbitMQ inside AnyEvent::Fork(::RPC)
use AnyEvent::RabbitMQ::Fork; my $cv = AnyEvent->condvar; my $ar = AnyEvent::RabbitMQ::Fork->new->load_xml_spec()->connect( host => 'localhost', port => 5672, user => 'guest', pass => 'guest', vhost => '/', timeout => 1, tls => 0, # Or 1 if you'd like SSL tune => { heartbeat => 30, channel_max => $whatever, frame_max = $whatever }, on_success => sub { my $ar = shift; $ar->open_channel( on_success => sub { my $channel = shift; $channel->declare_exchange( exchange => 'test_exchange', on_success => sub { $cv->send('Declared exchange'); }, on_failure => $cv, ); }, on_failure => $cv, on_close => sub { my $method_frame = shift->method_frame; die $method_frame->reply_code, $method_frame->reply_text; }, ); }, on_failure => $cv, on_read_failure => sub { die @_ }, on_return => sub { my $frame = shift; die "Unable to deliver ", Dumper($frame); }, on_close => sub { my $why = shift; if (ref($why)) { my $method_frame = $why->method_frame; die $method_frame->reply_code, ": ", $method_frame->reply_text; } else { die $why; } }, ); print $cv->recv, "\n";
This module is mean't to be a close to a drop-in facade for running AnyEvent::RabbitMQ in a background process via AnyEvent::Fork::RPC.
Tha main use case is for programs where other operations block with little control due to difficulty/laziness. In this way, the process hosting the connection RabbitMQ is doing nothing else but processing messages.
my $ar = AnyEvent::RabbitMQ::Fork->new();
Prints a LOT of debugging information to STDOUT.
STDOUT
Declare and load the AMQP Specification you wish to use. The default is to use version 0.9.1 with RabbitMQ specific extensions.
Returns: $self
Open connection to an AMQP server to begin work.
Arguments:
Open a logical channel which is where all the AMQP fun is.
Close this connection.
William Cox <mydimension@gmail.com>
Copyright (c) 2014, the above named author(s).
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install AnyEvent::RabbitMQ::Fork, copy and paste the appropriate command in to your terminal.
cpanm
cpanm AnyEvent::RabbitMQ::Fork
CPAN shell
perl -MCPAN -e shell install AnyEvent::RabbitMQ::Fork
For more information on module installation, please visit the detailed CPAN module installation guide.