line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Message::Passing::Output::AMQP; |
2
|
1
|
|
|
1
|
|
1969
|
use Moose; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
7
|
|
3
|
1
|
|
|
1
|
|
5337
|
use namespace::autoclean; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
10
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
with qw/ |
6
|
|
|
|
|
|
|
Message::Passing::AMQP::Role::DeclaresExchange |
7
|
|
|
|
|
|
|
Message::Passing::Role::Output |
8
|
|
|
|
|
|
|
/; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
has routing_key => ( |
11
|
|
|
|
|
|
|
isa => 'Str', |
12
|
|
|
|
|
|
|
is => 'ro', |
13
|
|
|
|
|
|
|
default => '', |
14
|
|
|
|
|
|
|
); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub consume { |
17
|
0
|
|
|
0
|
|
|
my $self = shift; |
18
|
0
|
|
|
|
|
|
my $data = shift; |
19
|
0
|
0
|
|
|
|
|
if (ref $data) { |
20
|
0
|
|
|
|
|
|
warn("Passed non-serialized data - is a perl reference. Dropping.\n"); |
21
|
0
|
|
|
|
|
|
return; |
22
|
|
|
|
|
|
|
} |
23
|
0
|
0
|
|
|
|
|
unless ($self->_exchange) { |
24
|
0
|
|
|
|
|
|
warn("No exchange yet, dropping message"); |
25
|
0
|
|
|
|
|
|
return; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
$self->_channel->publish( |
28
|
0
|
|
|
|
|
|
body => $data, |
29
|
|
|
|
|
|
|
exchange => $self->exchange_name, |
30
|
|
|
|
|
|
|
routing_key => $self->routing_key, |
31
|
|
|
|
|
|
|
); |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
35
|
|
|
|
|
|
|
1; |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=head1 NAME |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
Message::Passing::Output::AMQP - output messages to AMQP. |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=head1 SYNOPSIS |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
message-pass --input STDIN --output AMQP --output_options '{"exchange_name":"test","hostname":"127.0.0.1","username":"guest","password":"guest"}' |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=head1 DESCRIPTION |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
A L<Message::Passing> L<AnyEvent::RabbitMQ> output class. |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
Can be used as part of a chain of classes with the L<message-pass> utility, or directly as |
50
|
|
|
|
|
|
|
a logger in normal perl applications. |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=head1 METHODS |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=head2 consume |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
Sends a message. |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=head1 SEE ALSO |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=over |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=item L<Message::Passing::AMQP> |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=item L<Message::Passing::Input::AMQP> |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=item L<Message::Passing> |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=item L<AMQP> |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=item L<http://www.zeromq.org/> |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=back |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=head1 AUTHOR, COPYRIGHT AND LICENSE |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
See L<Message::Passing::AMQP>. |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=cut |
79
|
|
|
|
|
|
|
|