Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

What RabbitMQ Can Do For You (Nomad PHP May 2014)

1,200 views

Published on


RabbitMQ is a message broker – an application that allows communication between applications by way of a message queuing system. In this talk, we look at some of the basic concepts of RabbitMQ and how it can help effectively scale your applications.

These slides are for the lightning talk I gave at Nomad PHP on 22nd May 2014.

Published in: Internet, Technology, Design
  • Be the first to comment

  • Be the first to like this

What RabbitMQ Can Do For You (Nomad PHP May 2014)

  1. 1. What RabbitMQ Can Do For You James Titcumb Nomad PHP Lightning Talk May 2014
  2. 2. Who is this guy? James Titcumb www.jamestitcumb.com www.protected.co.uk www.phphants.co.uk @asgrim
  3. 3. What is message queuing?
  4. 4. Separate applications
  5. 5. Low cost parallelisation
  6. 6. Basic Example Publisher queue Consumer Based on: http://www.rabbitmq.com/tutorials/tutorial-one-php.html
  7. 7. Exchanges Based on: http://www.rabbitmq.com/tutorials/tutorial-three-php.html queue1 Publisher Publisher Publisher Publisher Exchange queue2 Consumer Consumer Consumer
  8. 8. Exchanges: Direct Based on: http://www.rabbitmq.com/tutorials/tutorial-four-php.html fruit Exchange vegetable Fruit consumer Veg consumer Fruit consumer Publisher routing key: fruit routing key: vegetable
  9. 9. Exchanges: Topic Based on: http://www.rabbitmq.com/tutorials/tutorial-five-php.html *.fruit Exchange green.* Fruit consumer Green consumer Veg consumer Publisher routing key: green.fruit routing key: green.vegetable *.vegetable
  10. 10. Real World Uses ● Fast logging solution ● Sending emails ● Sending SMS ● Background processing (e.g. analysing data)
  11. 11. Using in PHP? https://github.com/videlalvaro/php-amqplib
  12. 12. composer.json { "require": { "videlalvaro/php-amqplib": "2.*" } }
  13. 13. Set up the channel use PhpAmqpLibConnectionAMQPConnection; $connection = new AMQPConnection( 'localhost', 5672, 'guest', 'guest', '/'); $channel = $connection->channel(); $channel->queue_declare('my_queue', /* params... */); $channel->exchange_declare( 'my_exchange', 'fanout', /* params... */); $channel->queue_bind('my_queue', 'my_exchange');
  14. 14. Basic Publishing Example use PhpAmqpLibMessageAMQPMessage; $content = 'Hello world'; $message = new AMQPMessage($content); $channel->basic_publish($message);
  15. 15. Basic Consumer Example use PhpAmqpLibMessageAMQPMessage; $channel->basic_consume( 'my_queue', /* some more parameters */ function (AMQPMessage $message) { echo $message->body; } );
  16. 16. Questions?
  17. 17. Thank you! James Titcumb www.jamestitcumb.com www.protected.co.uk www.phphants.co.uk @asgrim Please feedback! https://joind.in/11350

×