NAME

Net::RabbitMQ::Simple - A simple syntax for Net::RabbitMQ

VERSION

This document describes NET::RabbitMQ::Simple version 0.0002

SYNOPSIS

use Net::RabbitMQ::Simple;

my $mq = mqconnect {
    hostname => 'localhost',
    user => 'guest',
    password => 'guest',
    vhost => '/'
};

exchange $mq, {
    name => 'mtest_x',
    type => 'direct',
    passive => 0,
    durable => 1,
    auto_delete => 0,
    exclusive => 0
};

publish $mq, {
    exchange => 'maketest',
    queue => 'mtest',
    route => 'mtest_route',
    message => 'message',
    options => { content_type => 'text/plain' }
};

consume $mq;
my $rv = $mq->recv();

# use Data::Dumper;
# print Dumper($rv);

mqdisconnect $mq;

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

mqconnect

Connect to AMQP server using librabbitmq.

my $mq = mqconnect ({
    user => 'guest'
    password => 'guest',
    vhost => '/',
    channel_max => 0,
    frame_max => 131072,
    heartbeat => 0
});

exchange

Declare an exchange for work.

exchange $mq, {
    name => 'name_of_exchange',
    exchange_type => 'direct',
    passive => 0,
    durable => 0,
    auto_delete => 1
};

exchange_delete

Delete an exchange if is possible.

exchange_delete $mq, {
    name => 'name_of_exchange',
    if_unused => 1,
    nowait => 0
};

exchange_publish

Publish a new message.

publish $mq, {
    exchange => 'exchange',
    queue => 'queue',
    route => 'route',
    message => 'message',
    options => { content_type => 'text/plain' }
};

consume

Consume messages from queue.

consume $mq, {
    queue => 'name'
};

get

Consume messages from queue, but return undef if doesn't have message.

get $mq, {
    queue => 'queue',
    options => { routing_key => 'foo' }
};

SUPPORT

SEE ALSO

Net::RabbitMQ, Devel::Declare

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.