0
RabbitMQ
 for perl mongers
__
      / `                __
      |  `             /`/ 
      _/` -"-/` / 
             |           |  |
             (...
AMQP
Advanced Message Queuing Protocol
message flow in
  RabbitMQ
RabbitMQ


       Exchange


   Queue     Queue
RabbitMQ   RabbitMQ


            Queue
RabbitMQ


 Queue
AMQP   XMPP   STOMP   HTTP


        RabbitMQ


AMQP   XMPP   STOMP   HTTP
AMQP   XMPP   STOMP   HTTP



        RabbitMQ             AMQP   XMPP   STOMP   HTTP



AMQP   XMPP   STOMP   HTTP       ...
nice pictures but how
   does it look like?
Net::AMQP(::Simple)
boilerplate
my $spec = {
    RemoteAddress   =>   '127.0.0.1',
    RemotePort      =>   { default =>   5672 },
    Username        => ...
send a hash
# conect to the server
Net::AMQP::Simple::connect($spec);

# push the message
Net::AMQP::Simple::pub( $queue, to_json($has...
receive a message
while ( !$done ) {
    check( Net::AMQP::Simple::poll() );
}

sub check {
    foreach my $_req (@_) {
        my $req = fr...
typical messaging flow
the “server”
Net::AMQP::Simple::connect($spec);
Net::AMQP::Simple::queue("web.domaindb.up");

while (1) {
    process( Net::AMQP::Simpl...
the “client”
Net::AMQP::Simple::connect($spec);
Net::AMQP::Simple::pub( $queue, to_json($hash) );
Net::AMQP::Simple::queue( $uuid, 'aut...
in plain english

• start a service that listens on a queue
• push a message to the service and tell the
  service how to ...
how to reply?

• use AMQP header fields

• roll your own protocol (JSON, XML, ...)
... roll your own
if you want to use the full power of RabbitMQ
AMQP   XMPP   STOMP   HTTP


        RabbitMQ


AMQP   XMPP   STOMP   HTTP
how to get started?
• http://rabbitmq.com (get rabbit here)
• http://github.com/norbu09/
 • net_amqp (has the Simple.pm)
 • RabbitIntro (some ...
or ask me

lenz@ideegeo.com

   @norbu09
thanks
credits
• the RabbitMQ guys for an awesome
  product
• iWantMyName for letting me play with all
  that stuff
• many guys o...
more credits
• http://www.ascii-art.com
• http://www.flickr.com/photos/revengingangel/
• http://www.flickr.com/photos/jeff62...
RabbitMQ for Perl mongers
RabbitMQ for Perl mongers
Upcoming SlideShare
Loading in...5
×

RabbitMQ for Perl mongers

11,927

Published on

A talk I held at perl mongers Wellington about RabbitMQ and Net::AMQP. A brief introduction to RabbitMQ and some basic code samples on how to use it from perl.

Published in: Technology
1 Comment
9 Likes
Statistics
Notes
No Downloads
Views
Total Views
11,927
On Slideshare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
139
Comments
1
Likes
9
Embeds 0
No embeds

No notes for slide

Transcript of "RabbitMQ for Perl mongers"

  1. 1. RabbitMQ for perl mongers
  2. 2. __ / ` __ | ` /`/ _/` -"-/` / | | | (d b) _/ / ,".|.'._/.'.|.", / /' _|_ '/ | / '-`"`-' | | | | | | / / | jgs / / / `"` : /'"` `""`""`
  3. 3. AMQP Advanced Message Queuing Protocol
  4. 4. message flow in RabbitMQ
  5. 5. RabbitMQ Exchange Queue Queue
  6. 6. RabbitMQ RabbitMQ Queue
  7. 7. RabbitMQ Queue
  8. 8. AMQP XMPP STOMP HTTP RabbitMQ AMQP XMPP STOMP HTTP
  9. 9. AMQP XMPP STOMP HTTP RabbitMQ AMQP XMPP STOMP HTTP AMQP XMPP STOMP HTTP RabbitMQ AMQP XMPP STOMP HTTP
  10. 10. nice pictures but how does it look like?
  11. 11. Net::AMQP(::Simple)
  12. 12. boilerplate
  13. 13. my $spec = { RemoteAddress => '127.0.0.1', RemotePort => { default => 5672 }, Username => { default => 'guest' }, Password => { default => 'guest' }, VirtualHost => { default => '/' }, Logger => 0, Debug => { default => {} }, Alias => { default => 'amqp_client' }, AliasTCP => { default => 'tcp_client' }, Callbacks => { default => {} }, channels => { default => {} }, is_started => { default => 0 }, };
  14. 14. send a hash
  15. 15. # conect to the server Net::AMQP::Simple::connect($spec); # push the message Net::AMQP::Simple::pub( $queue, to_json($hash) );
  16. 16. receive a message
  17. 17. while ( !$done ) { check( Net::AMQP::Simple::poll() ); } sub check { foreach my $_req (@_) { my $req = from_json($_req); print Dumper($req); $done = 1; } }
  18. 18. typical messaging flow
  19. 19. the “server”
  20. 20. Net::AMQP::Simple::connect($spec); Net::AMQP::Simple::queue("web.domaindb.up"); while (1) { process( Net::AMQP::Simple::poll() ); } sub process { foreach my $_req (@_) { my $req = from_json( $_req, { allow_nonref => 1 } ); ... }
  21. 21. the “client”
  22. 22. Net::AMQP::Simple::connect($spec); Net::AMQP::Simple::pub( $queue, to_json($hash) ); Net::AMQP::Simple::queue( $uuid, 'autodelete' ); while ( !$done ) { check( Net::AMQP::Simple::poll() ); } sub check { foreach my $_req (@_) { my $req = from_json($_req); print Dumper($req); $done = 1; } }
  23. 23. in plain english • start a service that listens on a queue • push a message to the service and tell the service how to reply (if needed) • listen on a temp queue for the response (if needed)
  24. 24. how to reply? • use AMQP header fields • roll your own protocol (JSON, XML, ...)
  25. 25. ... roll your own if you want to use the full power of RabbitMQ
  26. 26. AMQP XMPP STOMP HTTP RabbitMQ AMQP XMPP STOMP HTTP
  27. 27. how to get started?
  28. 28. • http://rabbitmq.com (get rabbit here) • http://github.com/norbu09/ • net_amqp (has the Simple.pm) • RabbitIntro (some samples) • Net_RabbitMQ_HTTP
  29. 29. or ask me lenz@ideegeo.com @norbu09
  30. 30. thanks
  31. 31. credits • the RabbitMQ guys for an awesome product • iWantMyName for letting me play with all that stuff • many guys on the mailing list for helping me out when i got stuck • Catalyst IT for the beers
  32. 32. more credits • http://www.ascii-art.com • http://www.flickr.com/photos/revengingangel/ • http://www.flickr.com/photos/jeff62138/
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×