This document provides an overview of enterprise messaging with RabbitMQ presented by Luis Majano. It begins with introductions and then outlines the agenda which includes why messaging is useful, different messaging implementations and protocols like AMQP, and a demonstration of RabbitMQ. The bulk of the document discusses messaging paradigms and concepts like producers, consumers, exchanges and queues. It explains RabbitMQ exchanges like direct, fanout and topic in more detail and provides examples of how RabbitMQ can be used in different customer use cases.
2. @lmajano
@ortussolutions
• Born in El Salvador
• Imported into the USA! Now Malaga!
• Computer Engineer
• CEO of Ortus Solutions (ortussolutions.com)
• Published Author
• Professional Open Source
• Host @ Modernize or Die Podcast
This is me
Luis F. Majano
Y muchos más
proyectos POSS.
9. How can we decouple knowledge?
How can we unblock?
• Blocks Requests
• Tight coupling
⚬ Sender always knows about receiver
⚬ Receiver knows about sender
• What if the call errors out?
• What if the call hangs?
• What if the receiver dies
Problems with RPC
10. • Integrate many internal/external systems
• Integrate many languages
• Increase decoupling
• Software/Hardware Federation
Integrations
11. • Work with X amount of servers
• Notify X amount of servers of stuff
• Move with many geo-located servers
• Be more reactive to exceptions
• Distributed logging
Scale
15. Messaging (EMB)
Producer
Consumer Consumer Consumer
Messaging Bus - Broker
Can be any
system or
language
Can be any
system or
language
Doesn’t care
about consumers
Asynchronous Does not get a
response
20. • AMQP Messaging Broker
• Other Protocols: MQTT, HTTP, STOMP
• Built on Erlang
• Extremely fast, reliable, and secure
• Polyglot:
c#, erlang, java, python, ruby, node, CFML, etc
• It’s like a post box, post office, and postman
23. • Producer
⚬ Application that sends the message
• Consumer
⚬ Application that receives the
message
• Connection
⚬ TCP Connection between
application and RabbitMQ
• Channel
⚬ A virtual connection inside a TCP
connection.
⚬ Multiplexing
• Users
⚬ You can identify yourself to Rabbit
with a username/password and
have assigned permissions
Concepts
24. Concepts
• Queue
⚬ A buffer that stores the message(s)
• Message
⚬ Info sent from producer to consumer
• Exchange
⚬ Receives messages and pushes them
to queues depending on routing rules.
Queues are bounds to exchanges.
• Binding
⚬ A link between a queue and an
exchange
• Routing Key
⚬ A key that the exchange looks to decide
how to route the message. Like an
address
25. How it Works?
Producer
Message
(Body+Routing Key)
Exchange (Bindings via Routing Key)
stock.
prices
stock.
run
log.
error
Cluster
Body = binary, json, anything
Routing key = Bindings
Queues
Queues are bound to exchanges with patterns
32. Exchange Properties
• Name
• The unique name of the exchange
• Durability
• Persistence of the exchange’s metadata and settings
• NOT the messages, that’s queue durability
• Default is non-durable
• Auto-Delete
• Deleted when no longer in use
33. Exchange types
• Direct Exchange
⚬ Routing based on the routing key
⚬ Unicast Routing
⚬ Pass messages to the queues bound
with that key
⚬ No mapping or extra fluff, just a
passthrough
⚬ Pre-Declared Names:
⚬ (Empty String)
⚬ amq.direct
35. Exchange types
• Fanout
⚬ Sends messages to all queues bound
to it and the routing key is ignored
⚬ One message to multiple recipients
⚬ No load balancing; everybody gets
the message
⚬ Similar to JMS
⚬ Great for global events, updating
realtime boards, distributed
notifications, etc.
36. Exchange types
• Topic
⚬ Binding pattern (routing key) is match
against the queue name
⚬ Not full regex
⚬ Ex: log.*, log#
⚬ Not like JMS Topics, forget JMS, this is
not JMS
37. Queue Properties
• Stores Messages
• FIFO - First In First Out
• Name
• Unique name of the queue
• Durability
• Default is non-durable (in-memory)
• Declare durable for persistence
• Exclusive
• If true, the Queue is deleted as soon as
the connection is closed. Only the
declaring party can send messages
• Auto-Delete
• If true, then it will be auto-deleted once
the last consumer has unsubscribed
38. Load Balancing + Ack (Acknowledgements)
Worker
Queue
Consumer
Consumer
Consumer
Messages are
round-robin to each
consumer
Consumers need to
ack or ignore
43. Customer Use Cases
Incoming lead system to create internal follow ups in
a separate system without polling for new leads in DB
44. Customer Use Cases
Aggregate real time changes to customer sales
made across multiple systems running different
versions of ColdFusion and Lucee to push real time
updates to dashboards and fire related processes.
45. Customer Use Cases
Leverage STOMP Rabbit Plugin for websockets to push
real time message to sales team agents as soon as a
new lead came in. Used topic exchange to broadcast
leads only to applicable team members and
enforced security via auth API.
47. Customer Use Cases
Implemented real time chat between Twillio-
powered SMS messages and web based chat UI on
site so sales teams could communicate with clients.
All messages were sent and received via websockets
powered by Rabbit and STOMP plugin.
48. Customer Use Cases
Created a delayed notification system to follow up
with clients after unread messages. Used delayed
message exchange to schedule followups based on
business rules. Eliminated all DB polling to check for
needed followups.
49. Customer Use Cases
Created user-specific notification queues to push
over websockets. Each queue topic is locked down to
specific users and authentication is provided by CF-
based API using JWT (JSON Web Token) from browser
to identify browser connections.