The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Net::AMQP::RabbitMQ::PP - Pure perl AMQP client for RabbitMQ

SYNOPSIS

    use Net::AMQP::RabbitMQ::PP;

    my $connection = Net::AMQP::RabbitMQ::PP->new();
    $connection->connect;
    $connection->basic_publish(
        payload => "Foo",
        routing_key => "foo.bar",
    );
    $connection->disconnect

DESCRIPTION

Like Net::RabbitMQ but pure perl rather than a wrapper around librabbitmq.

VERSION

0.11

SUBROUTINES/METHODS

A list of methods with their default arguments (undef = no default)

new

Loads the AMQP protocol definition, primarily. Will not be an active connection until ->connect is called.

        my $mq = Net::AMQP::RabbitMQ::PP->new;

connect

Connect to the server. Default arguments are shown below:

        $mq->connect(
                host           => "localhost",
                port           => 5672,
                timeout        => undef,
                username       => 'guest',
                password       => 'guest',
                virtual_host   => '/',
                heartbeat      => undef,
                socket_timeout => 5,
                frame_max      => 131072,
        );

connect can also take a secure flag for SSL connections, this will only work if IO::Socket::SSL is available. You can also pass SSL specific arguments through in the connect method and these will be passed through

        $mq->connect(
                ...
                secure => 1,
                SSL_blah_blah => 1,
        );

disconnect

Disconnects from the server

        $mq->disconnect;

set_keepalive

Set a keep alive poller. Note: requires Socket::Linux

        $mq->set_keepalive(
                idle     => $secs, # time between last meaningful packet and first keep alive
                count    => $n,    # number of failures to allow,
                interval => $secs, # time between keep alives
        );

receive

Receive the nextframe

        my $rv = $mq->receive;

Content or $rv will look something like:

        {
                payload              => $str,
                content_header_frame => Net::AMQP::Frame::Header,
                delivery_frame       => Net::AMQP::Frame::Method,
        }

channel_open

Open the given channel:

        $mq->channel_open( channel => undef );

exchange_declare

Instantiate an exchange with a previously opened channel:

        $mq->exchange_declare(
                channel            => undef,
                exchange           => undef,
                exchange_type      => undef,
                passive            => undef,
                durable            => undef,
                auto_delete        => undef,
                internal           => undef,
                alternate_exchange => undef,
        );

exchange_delete

Delete a previously instantiated exchange

        $mq->exchange_delete(
                channel   => undef,
                exchange  => undef,
                if_unused => undef,
        );

queue_declare

        $mq->exchange_declare(
                channel     => undef,
                queue       => undef,
                exclusive   => undef,
                passive     => undef,
                durable     => undef,
                auto_delete => undef,
                expires     => undef,
                message_ttl => undef,
        );

queue_bind

        $mq->queue_bind(
                channel     => undef,
                queue       => undef,
                exchange    => undef,
                routing_key => undef,
                headers     => {},
                x_match     => undef,
        );

queue_delete

        $mq->queue_delete(
                channel   => undef,
                queue     => undef,
                if_empty  => undef,
                if_unused => undef,
        );

queue_unbind

        $mq->queue_bind(
                channel     => undef,
                queue       => undef,
                exchange    => undef,
                routing_key => undef,
                headers     => {},
                x_match     => undef,
        );

queue_purge

        $mq->queue_purge(
                channel => undef,
                queue   => undef,
        );

basic_ack

        $mq->basic_ack(
                channel      => undef,
                delivery_tag => undef,
                multiple     => undef,
        );

basic_cancel_callback

        $mq->basic_cancel_callback(
                callback => undef,
        );

basic_cancel

        $mq->basic_cancel(
                channel      => undef,
                queue        => undef,
                consumer_tag => undef,
        );

basic_get

        $mq->basic_get(
                channel => undef,
                queue   => undef,
                no_ack  => undef,
        );

basic_publish

        $mq->basic_publish(
                channel     => undef,
                payload     => undef,
                exchange    => undef,
                routing_key => undef,
                mandatory   => undef,
                immediate   => undef,
                props       => {
                        content_type     => undef,
                        content_encoding => undef,
                        headers          => undef,
                        delivery_mode    => undef,
                        priority         => undef,
                        correlation_id   => undef,
                        reply_to         => undef,
                        expiration       => undef,
                        message_id       => undef,
                        timestamp        => undef,
                        type             => undef,
                        user_id          => undef,
                        app_id           => undef,
                        cluster_id       => undef,
                },
        );

basic_consume

        $mq->basic_consume(
                channel      => undef,
                queue        => undef,
                consumer_tag => undef,
                exclusive    => undef,
                no_ack       => undef,
        );

basic_reject

        $mq->basic_reject(
                channel      => undef,
                delivery_tag => undef,
                requeue      => undef,
        );

basic_qos

        $mq->basic_qos(
                channel        => undef,
                global         => undef,
                prefetch_count => undef,
                prefetch_size  => undef,
        );

transaction_select

transaction_commit

transaction_rollback

confirm_select

All take channel => $channel as args.

heartbeat

TODO

BUGS, LIMITATIONS, AND CAVEATS

Please report all bugs to the issue tracker on github. https://github.com/PayProp/net-amqp-rabbitmq/issues

One known limitation is that we cannot automatically send heartbeat frames in a useful way.

A caveat is that I (LEEJO) didn't write this, I just volunteered to take over maintenance and upload to CPAN since it is used in our stack. So I apologize for the poor documentation. Have a look at the tests if any of the documentation is not clear.

Another caveat is that the tests require MQHOST=a.rabbitmq.host to be of any use, they used to default to dev.rabbitmq.com but that is currently MIA. If MQHOST is not set they will be skipped.

SUPPORT

Use the issue tracker on github to reach out for support. https://github.com/PayProp/net-amqp-rabbitmq/issues

AUTHOR

Originally:

        Eugene Marcotte
        athenahealth
        emarcotte@athenahealth.com
        http://athenahealth.com

Current maintainer:

        leejo@cpan.org

Contributors:

        Ben Kaufman
        Jonathan Briggs
        Piotr Malek

LICENSE AND COPYRIGHT

Copyright 2013 Eugene Marcotte

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

The full text of the license can be found in the LICENSE file included with this module.

SEE ALSO

Net::RabbitMQ

Net::AMQP