Messag...::AMQP(3pm)

πŸ“¦
version 0.008 Β· 2 versions
  • 0.008 Β· debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking (latest)
  • 0.008 Β· ubuntu jammy
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

✨ Message::Passing::Output::AMQP ✨

okay bestie, listen πŸ’– this is a page from the User Contributed Perl Documentation collection, and it's literally about yeeting your messages into AMQP. come sit with me, we're doing this together 🫢


NAME πŸŽ€

Message::Passing::Output::AMQP β€” output messages to AMQP. that's it, that's the vibe, that's the whole job description πŸ’…


SYNOPSIS ✨

like, here's the whole thing in one iconic little line:

message-pass --input STDIN --output AMQP --output_options '{"exchange_name":"test","hostname":"127.0.0.1","username":"guest","password":"guest"}'

see how cute that is? STDIN goes in, AMQP comes out, and all the connection deets ride along inside --output_options. slay.


DESCRIPTION πŸ¦‹

so this is a Message::Passing output class built on top of AnyEvent::RabbitMQ β€” that's the whole personality 🌈

you can run it two ways, and honestly both are valid:

  • as one link in a whole chain of classes with the message-pass utility (the group-chat option, everyone's in the chat)
  • or directly, as a logger inside your normal everyday perl applications (the solo main-character option πŸ‘‘)

ATTRIBUTES πŸ’–

these are the lil knobs you can turn. get comfy.

routing_key

the routing key for every single message, no exceptions, no favourites. it defaults to '' β€” empty string, yes, that's the default, that's canon.

header_cb

an optional callback function ✨ it gets handed the message before it's serialized using serialize_cb. it should return a hashref, and that hashref gets passed to publish( header => ).

⚠️ NOTE bestie this is the important bit: if you want to set the message headers (note the s, plural, there's an s!!) you have to pass them inside headers, like this:
{
    content_type => 'application/json',
    headers => {
        key => 'value',
    }
}

see the headers inside the headers situation? nested. it's giving inception πŸ’€ don't fight it.

serialize_cb

another optional callback function 🫢 this one gets passed the message and should return a scalar. it's the moment for turning stuff into bytes basically.

it's super useful when you're passing structured messages β€” think hashrefs or objects β€” where some of those attributes need to stay reachable for the header_cb function. because listen: if the serialization already happened before a Message::Passing::Role::Filter did its thing, then header_cb would have to deserialize it all over again and nobody has time for that 😭

so if you wanna use a Message::Passing filter, you instantiate it and hand its filter function straight to serialize_cb, like so:

my $filter = Message::Passing::Filter::Encoder::JSON->new(output_to => undef);

...

{
    serialize_cb => sub { $filter->filter(shift) },
}

obsessed. ate. no crumbs. πŸ”₯


METHODS πŸ‘‘

consume

sends a message. that's the whole method. short, sweet, does exactly what it says on the tin πŸ’œ


SEE ALSO 🌸

go read these next, bestie, iykyk:


see Message::Passing::AMQP β€” yeah, that's literally where it all lives, go look πŸ‘€


k bye ily, this was the perl v5.36.0 era, dated 2022-11-19, from your friendly neighborhood Messag...::AMQP(3pm) page πŸ’–βœ¨πŸŽ€ stay hydrated and always pass your messages correctly πŸ¦‹