Mike Willbanks Sr. Software Engineer at CaringBridge Blog:  http://blog.digitalstruct.com Twitter : mwillbanks IRC : lubs on freenode Talk:  http://joind.in/1586 The Art of Message Queues TEK-X
Who Am I? Sr. Sofware Engineer at CaringBridge
PHP monkey
MNPHP User Group
Interested in Scalability & Performance
“ Message queues and mailboxes are software-engineering components used for interprocess communication, or for inter-thread communication within the same process. They use a queue for messaging – the passing of control or of content.” http://en.wikipedia.org/wiki/Message_queue
“ Messaging describes the sending and receiving of data (in the form of messages) between systems. Messages are exchanged between programs or applications, similar to the way people communicate by email but with guarantees on delivery, speed, security and the absence of spam.” http://www.rabbitmq.com/faq.html#what-is-messaging
Messages are Everywhere
A Basic Message Queue
What are Message Queues A FIFO buffer
Asynchronous push / pull
An application framework for sending and receiving messages.
A way to communicate between applications / systems.
A way to decouple components.
A way to offload work.
Why are Message Queues Useful? Asynchronous Processing
Communication between Applications / Systems
Image Resizing
Video Processing
Sending out Emails
Auto-Scaling Virtual Instances
Log Analysis
The list goes on...
You Might Use a Message Queue If... The request can be fulfilled in the background.
You need to communicate between multiple applications / systems.
You have a limited number of processing slots.
You need to support legacy applications or use multiple programming languages. Good short presentation on why you might need it: blog.pasker.net/2008/06/16/you-might-need-messaging-if/
Going back to Unix “Write programs that work together.”
“Do it in the background.”
Why does that matter? Web systems need to be geared to run things asynchronously.
Distribution may also come into play.
Protocols
Standardized Protocols AMQP – Advanced Message Queue Protocol
STOMP – Streaming Text Oriented Messaging Protocol
XMPP - Extensible Messaging and Presence Protocol Related with patches, I will not be going into this.  However, XMPP is the next topic in this room.
AMQP
Overview AMQP Working Group (Community and Vendor)
Platform agnostic protocol.
Completely open, interoperable and broadly applicable.
Many severs available and many client libraries. http://amqp.org  For more information on the protocol.
How it works. AMQP utilizes exchanges, queues and bindings.
An exchange is routers with routing tables.
A queue is where the messages wait for a consumer.
A binding defines the routing rules.
In a nutshell....
Some of the Various Servers Apache Qpid - qpid.apache.org
OpenAMQ - openamq.org
RabbitMQ - rabbitmq.com
ZeroMQ - zeromq.org
A PHP Client php-rabbit – code.google.com/p/php-rabbit Looks like it will become a PECL package at some point: pecl.php.net/package/amqp.
Installation can be a bit painful since the c client needs to be linked.
Exchanges Fanout Exchange No routing keys involved.  Any message that is sent to the exchange is sent to all queues bound to that exchange. Direct Exchange Routing keys involved.  A queue binds to the exchange to request messages that match a routing key exactly. Topic Exchange Routing keys involved.  A queue binds to the exchange to request messages that match a routing key pattern.
Enough Text, lets see a picture
Your First Queue An exchange, queue and bindings must be defined first.  Publishing can then commence after. Create the queue
Create the exchange
Bind to the queue.

The Art of Message Queues - TEKX