An introduction to message queues with PHP. We'll focus on RabbitMQ and how to leverage queuing scenarios in your applications. The talk will cover the main concepts of RabbitMQ server and AMQP protocol and show how to use it in PHP. The RabbitMqBundle for Symfony2 will be presented and we'll see how easy you can start to use message queuing in minutes.
Presented at Symfony User Group Belgium: http://www.meetup.com/Symfony-User-Group-Belgium/events/169953362/
4. RabbitMQ
• Message Broker
• Open Source
• AMPQ implementation
• Written in Erlang
• Lots of AMQP client libraries
• Wide community and commercial support
6. Use Cases
• Send notifications to users
• Process heavy work/tasks with multiple workers
Upload picture, make thumbnails, clear CDN caches…
• Distribute logs/messages to multiple endpoints
• Interoperability between different platforms
• Remote Procedure Call
7. AMQP
Advanced Message Queuing Protocol
• Open Standard Protocol coming from finance
• Interoperable Messaging Middleware
• Queuing
• Routing (point-to-point and publish-and-subscribe)
• Reliability
• Security
12. Topic Exchange
A Topic Exchange sends a message to a queue if the message's
routing key matches the binding key for the queue, using wildcard matching
20. Work Queues / Task Queues
• Avoid doing a resource-intensive task immediately
• Schedule the task to be done later
• Encapsulate a task as a message and send it to a
queue
• A worker process running in the background will
execute the job
• Multiple workers will share tasks
23. Publish/Subscribe
• Task queues: task is delivered to exactly one worker
• Pub/Sub: deliver a message to multiple consumers
• Published messages are going to be broadcast to all
the receivers
• Fanout exchanges
29. Topics
• Direct exchanges cannot do routing based on multiple criteria
• Example: how to combine “severity” and “resource”
• Topic exchange: messages are sent with a routing key
composed by a list of words, delimited by dots
• * (star) can substitute for exactly one word
• # (hash) can substitute for zero or more words
32. RPC
• Work Queues = distribute time-consuming tasks
among multiple workers
• Remote Procedure Call or RPC = run a function on a
remote computer and wait for the result