RabbitMQ for Perl mongers
Upcoming SlideShare
Loading in...5
×
 

RabbitMQ for Perl mongers

on

  • 14,503 views

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.

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.

Statistics

Views

Total Views
14,503
Views on SlideShare
14,095
Embed Views
408

Actions

Likes
9
Downloads
131
Comments
1

7 Embeds 408

http://norbu09.org 325
http://www.slideshare.net 63
http://localhost 13
http://paper.li 4
http://twitter.com 1
http://flavors.me 1
http://www.linkedin.com 1
More...

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel

11 of 1

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    RabbitMQ for Perl mongers RabbitMQ for Perl mongers Presentation Transcript

    • RabbitMQ for perl mongers
    • __ / ` __ | ` /`/ _/` -"-/` / | | | (d b) _/ / ,".|.'._/.'.|.", / /' _|_ '/ | / '-`"`-' | | | | | | / / | jgs / / / `"` : /'"` `""`""`
    • 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 RabbitMQ 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 => { 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 }, };
    • send a hash
    • # conect to the server Net::AMQP::Simple::connect($spec); # push the message Net::AMQP::Simple::pub( $queue, to_json($hash) );
    • receive a message
    • while ( !$done ) { check( Net::AMQP::Simple::poll() ); } sub check { foreach my $_req (@_) { my $req = from_json($_req); print Dumper($req); $done = 1; } }
    • typical messaging flow
    • the “server”
    • 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 } ); ... }
    • the “client”
    • 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; } }
    • 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)
    • 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 samples) • Net_RabbitMQ_HTTP
    • 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 on the mailing list for helping me out when i got stuck • Catalyst IT for the beers
    • more credits • http://www.ascii-art.com • http://www.flickr.com/photos/revengingangel/ • http://www.flickr.com/photos/jeff62138/