File: BindsAQueue.pm

package info (click to toggle)
libmessage-passing-amqp-perl 0.003-3
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 268 kB
  • ctags: 139
  • sloc: perl: 1,654; makefile: 12
file content (63 lines) | stat: -rw-r--r-- 1,301 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package Message::Passing::AMQP::Role::BindsAQueue;
use Moose::Role;
use Scalar::Util qw/ weaken /;
use namespace::autoclean;

with qw/
    Message::Passing::AMQP::Role::DeclaresExchange
    Message::Passing::AMQP::Role::DeclaresQueue
/;

has bind_routing_key => (
    isa => 'Str',
    is => 'ro',
    default => '#',
);

after [qw[_set_queue ]] => sub {
    my $self = shift;
    if ($self->_has_exchange && $self->_has_queue) {
        weaken($self);
        $self->_channel->bind_queue(
           queue => $self->queue_name,
           exchange => $self->exchange_name,
           routing_key => $self->bind_routing_key,
           on_success => sub {
                #warn("Bound queue");
           },
           on_failure => sub {
                warn("Failed to bind queue");
           },
        );
    }
};

1;

=head1 NAME

Message::Passing::AMQP::Role::BindsAQueue

=head1 DESCRIPTION

Role for components which cause a single queue to be bound to a single exchange with a single routing key.

=head1 ATTRIBUTES

=head2 bind_routing_key

Defaults to C<#>, which matches any routing key.

=head1 CONSUMES

=over

=item L<Message::Passing::AMQP::Role::BindsQueues>

=item L<Message::Passing::AMQP::Role::DeclaresExchange>

=item L<Message::Passing::AMQP::Role::DeclaresQueue>

=back

=cut