What RabbitMQ Can Do For You
James Titcumb
Nomad PHP Lightning Talk
May 2014
Who is this guy?
James Titcumb
www.jamestitcumb.com
www.protected.co.uk
www.phphants.co.uk
@asgrim
What is message queuing?
Separate applications
Low cost parallelisation
Basic Example
Publisher
queue
Consumer
Based on: http://www.rabbitmq.com/tutorials/tutorial-one-php.html
Exchanges
Based on: http://www.rabbitmq.com/tutorials/tutorial-three-php.html
queue1
Publisher
Publisher
Publisher
Publish...
Exchanges: Direct
Based on: http://www.rabbitmq.com/tutorials/tutorial-four-php.html
fruit
Exchange
vegetable
Fruit consum...
Exchanges: Topic
Based on: http://www.rabbitmq.com/tutorials/tutorial-five-php.html
*.fruit
Exchange
green.*
Fruit consume...
Real World Uses
● Fast logging solution
● Sending emails
● Sending SMS
● Background processing (e.g. analysing data)
Using in PHP?
https://github.com/videlalvaro/php-amqplib
composer.json
{
"require": {
"videlalvaro/php-amqplib": "2.*"
}
}
Set up the channel
use PhpAmqpLibConnectionAMQPConnection;
$connection = new AMQPConnection(
'localhost', 5672, 'guest', '...
Basic Publishing Example
use PhpAmqpLibMessageAMQPMessage;
$content = 'Hello world';
$message = new AMQPMessage($content);...
Basic Consumer Example
use PhpAmqpLibMessageAMQPMessage;
$channel->basic_consume(
'my_queue',
/* some more parameters */
f...
Questions?
Thank you!
James Titcumb
www.jamestitcumb.com
www.protected.co.uk
www.phphants.co.uk
@asgrim
Please feedback!
https://join...
Upcoming SlideShare
Loading in...5
×

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

571

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
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
571
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
9
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

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
  1. A particular slide catching your eye?

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

×