Net::AMQP(3pm)

πŸ’Œ Net::AMQP(3pm) β€” the perl manpage, but make it group chat πŸ’Œ

okay bestie, so this is Net::AMQP from section 3pm of the perl manual β€” yes, the whole (de)serialization + representation situation for the Advanced Message Queue Protocol, explained by someone who actually read the whole thing 🫢


✨ NAME ✨

Net::AMQP β€” Advanced Message Queue Protocol (de)serialization and representation. like, the module that turns AMQP frames into perl objects and back again. slay.


🌸 SYNOPSIS 🌸

  use Net::AMQP;

  Net::AMQP::Protocol->load_xml_spec('amqp0-8.xml');

  ...

  my @frames = Net::AMQP->parse_raw_frames(\$input);

  ...

  foreach my $frame (@frames) {
      if ($frame->can('method_frame') && $frame->method_frame->isa('Net::AMQP::Protocol::Connection::Start')) {
          my $output = Net::AMQP::Frame::Method->new(
              channel => 0,
              method_frame => Net::AMQP::Protocol::Connection::StartOk->new(
                  client_properties => { ... },
                  mechanism         => 'AMQPLAIN',
                  locale            => 'en_US',
                  response          => {
                      LOGIN    => 'guest',
                      PASSWORD => 'guest',
                  },
              ),
          );
          print OUT $output->to_raw_frame();
      }
  }

the ... bits are literally the original's ..., not me being lazy, i promise 😭 that's the whole vibe β€” load a spec, parse some frames, then when a frame is giving Connection::Start energy you fire back a Connection::StartOk with channel => 0, an AMQPLAIN mechanism, locale of 'en_US', and the classic LOGIN/PASSWORD guest/guest moment πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

this module implements the frame (de)serialization and representation of the Advanced Message Queue Protocol (<http://www.amqp.org/>).

and like β€” important β€” it's meant to be used together with client or server software that does the actual TCP/IP communication. Net::AMQP is not out here opening sockets, no cap. it just does the wire-format representation thing, which honestly? iconic division of labor ✨


πŸ‘‘ CLASS METHODS πŸ‘‘

πŸŽ€ parse_raw_frames

  Net::AMQP->parse_raw_frames(\$binary_payload)

you hand it a scalar reference that points at a binary string, and it hands you back a list of Net::AMQP::Frame objects β€” and heads up, it consumes the data in that string while it's at it (yes, it eats the string, she's hungry πŸ“).

and if the input is invalid? it croaks. like, literally croaks. loud. πŸ’€


🌈 SEE ALSO 🌈

  • Net::AMQP::Value
  • Net::RabbitMQ
  • AnyEvent::RabbitMQ
  • Net::RabbitFoot
  • POE::Component::Client::AMQP

go read those too, they're the friend group πŸ’œ


πŸ”₯ AMQP VERSIONS πŸ”₯

  • AMQP 0-8 is fully supported. ate, no crumbs. πŸ‘‘
  • AMQP 0-9, 0-9-1, and 0-10 are usably supported. and here's the tea: there are interoperability issues with table encodings, because the standard disagrees with the dialects of the major implementations (RabbitMQ and Qpid) 😭 so for now, Net::AMQP limits itself to universally agreed table elements. details are over at <http://www.rabbitmq.com/amqp-0-9-1-errata.html>.
  • AMQP 1.0 has not been tested. so, like, she's untested. proceed accordingly πŸ™ˆ

πŸ’€ TODO πŸ’€

so the todo is to address the dialect problem, and there are two (2) paths, bestie:

  1. modified spec files that completely control the wire protocol, or
  2. a programmatic request.

the first one has precedent (viz "qpid.amqp0-8.xml" in spec), but it could cause a combinatorial explosion as more brokers and versions get added 😭 and the second one adds interface complexity.

either way, it's a whole thing. not me volunteering though πŸ’…


⭐ QUOTES ⭐

"All problems in computer science can be solved by another level of indirection." β€” David Wheeler's observation
"...except for the problem of too many layers of indirection." β€” Kevlin Henney's corollary

ngl this is the best part of the whole page and i will not be taking questions 🌸


Copyright (c) 2009 Eric Waters and XMission LLC (<http://www.xmission.com/>). Copyright (c) 2012, 2013 Chip Salzenberg and Topsy Labs (<http://labs.topsy.com/>). All rights reserved.

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.


πŸ’– AUTHOR πŸ’–

Eric Waters <ewaters@gmail.com>


and that's the whole page, bestie 🫢 generated by perl v5.42.0, dated 2016-11-28, and it's the Net::AMQP(3pm) manual β€” go forth and serialize your frames responsibly πŸ’…βœ¨πŸŽ€

πŸ“¦ where this page comes from