NAME
Net::RabbitMQ::Simple - A simple syntax for Net::RabbitMQ
SYNOPSIS
use Net::RabbitMQ::Simple;
mqconnect {
hostname => 'localhost',
user => 'guest',
password => 'guest',
vhost => '/'
};
exchange {
name => 'mtest_x',
type => 'direct',
passive => 0,
durable => 1,
auto_delete => 0,
exclusive => 0
};
publish {
exchange => 'maketest',
queue => 'mtest',
route => 'mtest_route',
message => 'message',
options => { content_type => 'text/plain' }
};
my $rv = consume;
# or
# my $rv = get { options => { routing_key => 'foo.*' }}
# use Data::Dumper;
# print Dumper($rv);
mqdisconnect;
DESCRIPTION
This package implements a simple syntax on top of Net::RabbitMQ. With the help of this package it is possible to write simple AMQP applications with a few lines of perl code.
METHODS
All methods, unless specifically stated, return nothing on success and die on failure.
mqconnect %hash
Connect to AMQP server using librabbitmq.
This method returns the Net::RabbitMQ object.
{
user => 'guest'
password => 'guest',
vhost => '/',
channel_max => 0,
frame_max => 131072,
heartbeat => 0
}
exchange %hash
Declare an exchange for work.
{
name => 'name_of_exchange',
exchange_type => 'direct',
passive => 0,
durable => 0,
auto_delete => 1
}
exchange_delete %hash
Delete an exchange if is possible.
exchange_delete {
name => 'name_of_exchange',
if_unused => 1,
nowait => 0
}
exchange_publish %hash
Publish a new message.
{
exchange => 'exchange',
queue => 'queue',
route => 'route',
message => 'message',
options => { content_type => 'text/plain' }
}
consume %hash
Consume messages from queue.
{
queue => 'name'
}
get %hash
Consume messages from queue, but return undef if doesn't have message.
{
queue => 'queue',
options => { routing_key => 'foo' }
}
tx
Start a server-side transaction over channel.
commit
Commit a server-side transaction over channel.
rollback
Rollback a server-side transaction over channel.
purge
Purge queue.
ack
Need acknowledged.
mqdisconnect
Disconnect from server.
mqobject $object
Set current Net::RabbitMQ object.
TEST
Its necessary to set MQHOST environment variable for run all tests. For example:
MQHOST=localhost make test
SUPPORT
RT: CPAN's request tracker
AnnoCPAN: Annotated CPAN documentation
CPAN Ratings
Search CPAN
SEE ALSO
AUTHOR
Thiago Rondon. <thiago@aware.com.br>
LICENSE AND COPYRIGHT
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See perlartistic.