NAME
Message::Passing::Output::AMQP - output messages to AMQP.
SYNOPSIS
message-pass --input STDIN --output AMQP --output_options '{"exchange_name":"test","hostname":"127.0.0.1","username":"guest","password":"guest"}'
DESCRIPTION
A Message::Passing AnyEvent::RabbitMQ output class.
Can be used as part of a chain of classes with the message-pass utility, or directly as a logger in normal perl applications.
ATTRIBUTES
routing_key
The routing key for all messages, defaults to ''.
header_cb
Optional callback function which gets passed the message before it is serialized using "serialize_cb". Should return a hashref which gets passed to publish( header => ).
NOTE: if you want to set the message headers (note the s) you have to pass them inside headers, e.g.:
{
content_type => 'application/json',
headers => {
key => 'value',
}
}
serialize_cb
Optional callback function which gets passed the message and should return a scalar. This is useful when passing structured messages e.g. hashrefs or objects where some attributes should be accessible for the "header_cb" function. If the serialization happens before using a Message::Passing::Role::Filter it would require to deserialize it again in header_cb. To use a Message::Passing filter you can instantiate it and pass it's filter function to serialize_cb:
my $filter = Message::Passing::Filter::Encoder::JSON->new(output_to => undef);
...
{
serialize_cb => sub { $filter->filter(shift) },
}
METHODS
consume
Sends a message.