2. What is Messaging system ?
System that allow applications to send and receive messages
• Allows application modules to be distributed over heterogeneous platforms
• Reduces the complexity of developing applications
• Creates a distributed communications layer
Benefits of Messaging ?
Why using Messaging?
• Get data from point A to point B
• Decouple publishers and consumers
• Queueing for later delivery
• Asynchronous
• Load balancing and scalability
3. RabbitMQ
What is RabbitMQ ?
Message broker, accept messages and forward messages
Like Postman and PostOffice
Why RabbitMQ ?
• Message durability and routing
• Clustering and high availability support
• Multi-protocol
• Many Clients (PHP, Java,C, Erlang, ruby)
• Tracing
• Management UI
• Access control
4. How it works ?
Protocol components?
RabbitMQ based on AMQP (Advanced Messaging Queuing Protocol)
AMQP use publisher, consumers, Exchange and Queue
Publisher : User application that sends messages
Exchange : Receive from Publisher and push to Queue
Queue : Buffer that stores messages
Consumer : User application that receives messages
How it works ?
Publisher connect to AMQ with a virtual host it intends to operate
Server check the access control for the Publisher on this virtual host
Publisher send it’s message to Exchange
Exchange delivers messages to Queues
Queue store messages for Consumer
Consumer pull messages from Queue
5. In-depth
Can be persistent
Can be deleted when empty
Can be deleted when server stops
Queues
Messages
Messages carry content (header + body)
Content body is opaque block of binary data
Broker never modifies content body
Exchange
Route messages based on criteria
Doesn’t store messages
can inspect message content
can be created at runtime
Bindings
Relationship between an exchange and a queue
Can take an extra routing_key parameter
Meaning of a binding key depends on the exchange type
6. Exchange types
Direct
Direct exchange delivers messages to queues based on a message routing key
direct exchange is ideal for the unicast routing of messages
Fanout
Fanout routes messages to all of the queues
that are bound to it and the routing key is ignored
ideal for the broadcast routing of messages.