messaging for modern applications
TRANSCRIPT
1CONFIDENTIAL 1CONFIDENTIAL
Taking the next step shouldn’t be scary …
Messaging for Modern Applications
© 2010 SpringSource, A division of VMware. All rights reserved
CONFIDENTIAL
© 2010 SpringSource, A division of VMware. All rights reserved
CONFIDENTIAL
Messaging for Modern Applications
Pronam Chatterjee, Staff Systems Engineer, VMware
Email: [email protected]
Twitter: pronamc
3CONFIDENTIAL 3CONFIDENTIAL
Session Agenda
• Modern Applications
– Trends and Impact on Messaging
– Impact on Application Architecture
• Spring Integration
– Messaging Use Cases
– Messaging DSL for Spring Applications
• AMQP
– Why AMQP?
– AMQP Architecture
• RabbitMQ
– Why RabbitMQ?
– RabbitMQ Architecture
4CONFIDENTIAL 4CONFIDENTIAL
Modern Application Trends
• Written with frameworks
– Developer productivity and innovation
• New Application Types
– Mobile, SaaS, Social
– Apps released early and often
• Data intensive
– Emerging requirements: elasticity, multi-cloud
– Web orientation drives exponential data
volumes
• Deployed on virtual and cloud infrastructure
– Trending toward hybrid (public and private)
infrastructure
5CONFIDENTIAL 5CONFIDENTIAL
Today’s Middleware and Databases Not Keeping Up
Rise of Modern Developer Frameworks
Rise of Virtual and Cloud Infrastructure
Today’sMiddleware and Databases
ServiceConsumption
Polyglot
ServiceDelivery
ElasticDeployment
VirtualizationAware
LooseCoupling
Simplicity
ElasticScaling
6CONFIDENTIAL 6CONFIDENTIAL
Modern Applications need Modern Messaging
Modern approaches to messaging
embrace the unpredictable, dynamic,
and transient nature of the web
Traditional approaches to messaging
imply predictable, static interaction
between well-known end-points
7CONFIDENTIAL 7CONFIDENTIAL
Synchronous Architecture is Brittle
Place
Order
Fulfill
Order
Manage
Inventory
Schedule
Delivery
If any component is unavailable within this synchronous flow, all
in-flight messages will be affected, regardless of what component
they are currently in -- and since state is maintained across the
components, the system can be complex to reset
XX
XX
XX
XX
X
An exception
occurred,
please resend
8CONFIDENTIAL 8CONFIDENTIAL
Asynchronous Architecture Rules the Web
In this asynchronous flow:
• all state is kept in the simple messages being passed
• each stateless component interacts only with the broker cloud
• if a component is lost, only the in-flight messages within that
component must be re-delivered
• components can be quickly provisioned on-demand
I have an
Order
I can fulfill
part of
that Order
I’ll schedule
delivery of
that order
I can fulfill
part of
that OrderYour order will
be delivered
next Tuesday
The status of
your order is
…
9CONFIDENTIAL 9CONFIDENTIAL
How is Messaging Used within Modern Apps?
EventI need to know when to do something
Fragment
I need to only give you a piece of this data
Route
Control who gets which message, without changing sender or receiver
Batch
Producer and consumer can run at independent times
Publish
Tell everyone who wants to know about this
Modularity
Deploy, Scale, and Version a distributed system
10CONFIDENTIAL 10CONFIDENTIAL
Spring Integration
11CONFIDENTIAL 11CONFIDENTIAL
What is Spring Integration?
• At the core, an embedded Message Bus
– Inspired by Gregor Hohpe and Bobby Woolf's Enterprise Integration Patterns (2004)
– Runs within any Spring ApplicationContext
– All components are Spring-managed objects
• Also, an Application Integration Framework
– Connects to other systems via adapters
– Unidirectional Channel Adapters
– Bidirectional Messaging Gateways
12CONFIDENTIAL 12CONFIDENTIAL
Event
I need to know when to do something …
<service-activator
input-channel="hotDrinks”
ref="barista"
method="prepareHotDrink"
output-channel="preparedDrinks” />
An Event-Driven Consumer is one that is automatically handed
messages as they’re delivered on the channel. The receiver acts like
the message delivery is an event that triggers the receiver into action.
13CONFIDENTIAL 13CONFIDENTIAL
Fragment
I need to only give you this piece of data …
<int:splitter
input-channel="orders”
expression="payload.items”
output-channel="drinks” />
Use a Splitter to break out the composite message into a series of
individual messages, each containing data related to one item.
14CONFIDENTIAL 14CONFIDENTIAL
Route
Control who gets what message
<int:router
input-channel="drinks”
expression="payload.iced ? 'coldDrinks' :
'hotDrinks'” />
A Router consumes a Message from one Channel and republishes it to a
different Channel channel depending on a set of conditions.
15CONFIDENTIAL 15CONFIDENTIAL
Batch
Producer and Consumer can run at independent times
<int:channel id="preparedDrinks"/>
<int:aggregator
input-channel="preparedDrinks"
method="prepareDelivery"
output-channel="deliveries” >
<bean
class="org.sf.integration.samples.cafe.xml.Waiter"/>
</int:aggregator>
Use a stateful filter, an Aggregator, to collect and store individual
messages until a complete set of related messages has been received,
then publish a single message distilled from the individual messages.
16CONFIDENTIAL 16CONFIDENTIAL
Publish
Tell everyone who wants to know about this
<int-event:outbound-channel-adapter
channel="eventChannel"/>
All messages sent to the 'eventChannel' channel will be published as
ApplicationEvents to any relevant ApplicationListener instances that are
registered within the same Spring ApplicationContext.
17CONFIDENTIAL 17CONFIDENTIAL
Modularity
Deploy, Scale, Version a distributed system
Distributed
<int-amqp:outbound-gateway
id="coldDrinksBarista"
request-channel="coldDrinks”
reply-channel="preparedDrinks”
routing-key="ordered.drinks.cold” />
<int-amqp:outbound-gateway
id="hotDrinksBarista"
request-channel="hotDrinks”
reply-channel="preparedDrinks”
routing-key="ordered.drinks.hot” />
Spring Integration doesn’t force you to finalize decisions about deployment
before testing begins. Individual modules can be versioned, deployed, and
scaled independently at any time through configuration, not code.
Local
<service-activator
input-channel="coldDrinks”
ref="barista”
method="prepareColdDrink”
output-channel="preparedDrinks” />
<service-activator
input-channel="hotDrinks”
ref="barista"
method="prepareHotDrink"
output-channel="preparedDrinks” />
18CONFIDENTIAL 18CONFIDENTIAL
Advanced Message Queuing Protocol
(AMQP)
19CONFIDENTIAL 19CONFIDENTIAL
Advanced Message Queuing Protocol
SMTP AMQP
HTTP IIOP
unreliable reliable
async
sync
“Like email, but you can send money over it” Open, Ubiquitous,
and Adaptable
20CONFIDENTIAL 20CONFIDENTIAL
Why AMQP?
A Protocol, not an API• A defined set of messaging
capabilities called the AMQ model
• A network wire-level protocol, AMQP
On commodity hardware• 10-25 thousand messages
per second is routine *• The NIC is usually the
bottleneck
* Non-persistent messages
21CONFIDENTIAL 21CONFIDENTIAL
Why AMQP?
AMQP security• Brokers support separate
virtual hosts• Three levels of permissions• AMQP over SSL is supported
Designed to scale horizontally• Dozens of clustered brokers
are common• JPMorgan sends 1 billion
AMQP messages per day
22CONFIDENTIAL 22CONFIDENTIAL
AMQP Architecture
new.order
queue
M3M1 M2new.order
binding
new.order
routing key
23CONFIDENTIAL 23CONFIDENTIAL
AMQP Architecture
café NA deliveries
queue
café deliveries
queue
M3M1 M2
M3M1 M2
café WW deliveries
queue
M3M1 M2
24CONFIDENTIAL 24CONFIDENTIAL
AMQP Architecture
hot_drinks
queue
cold_drinks
queue
1 2
2
3
1
drink.cold
Message Routing Keys:
1. drink.hot
2. drink.cold
3. drink.warm
all_drinks
queue
25CONFIDENTIAL 25CONFIDENTIAL
RabbitMQ
26CONFIDENTIAL 26CONFIDENTIAL
Legacy Middleware not suited for Modern Apps
Costly to Scale Up Complex to Scale Out
Existing middleware impacts agility by tightly
coupling applications to underlying application server
and other middleware components
Apps &
Middleware
Licensed by Peak Physical Servers
27CONFIDENTIAL 27CONFIDENTIAL
RabbitMQ – Messaging that Just Works
design goal: no bloat - “it just works”
mission: “be everywhere”
AMQP LEADER
28CONFIDENTIAL 28CONFIDENTIAL
Incredible Community Lowers Your Cost of Use
11s t: 4EK-$?+%([: \(! "##$%(>, : +/ 484?$, . (@%0`
! "##$%& ' ($/%, ?-"%, . (* $%+(C 4.%(4F(%+, (C "$/ (0, 3, 84E, -(E8"i 4-C .
! "##$%(0$.%-$#G%, 0(#K(C 4.%(@$/G9(%KE, (E8"i 4-C .
A , (4^, -(E": T"?, . (F4-(C "/K(4%+, -(=Q(E8"i 4-C .
! "##$%& ' j̀ <>("/ 0(& $: -4. 4R(2g7(E"-%/ , -. +$E
; 84G0("/ 0(WG$80H! G/H& "/ "?, (* $88(0-$3, (C 4-, (. "8, .
& "-T, %(, /%-Ke("??-, . . $3, (m4E, / ](0$.%-$#G64/ (u(EG88(F4-(. "8, . ("/ 0(: 4C C , -: $"8(= <&
Monday, 17 August 2009
29CONFIDENTIAL 29CONFIDENTIAL
Enterprise Users, such as this Tier-1 Telco
30CONFIDENTIAL 30CONFIDENTIAL
Enterprise Features, such as Clustering
RMQ Cluster1
RMQ2
RMQ1queue-1
queue-2
RMQ3queue-3
1
3
2
1. queue-1
2. queue-3
3. queue-2
31CONFIDENTIAL 31CONFIDENTIAL
Enterprise Features, such as Fault Tolerance
ESX1
RMQ1
hot-drinks
cold-drinks
slave
master
VM2
RMQ2
hot-drinks
cold-drinkscold-drinks
VM1
RMQ1
hot-drinks
cold-drinks
32CONFIDENTIAL 32CONFIDENTIAL
Summary
• Modern Applications
– Use frameworks, less emphasis on servers
– The explosion of connected mobile devices
requires a new solution for messaging
• Spring Integration
– A DSL for introducing messaging abstractions
into your spring application
– Externalizes messaging concepts from code
• AMQP
– A TCP/IP protocol not an API
– Fast, Reliable, Open, Secure, Scalable
• RabbitMQ
– AMQP Leader
– Backed by VMware
© 2010 SpringSource, A division of VMware. All rights reserved
CONFIDENTIAL
© 2010 SpringSource, A division of VMware. All rights reserved
CONFIDENTIAL
Messaging for Modern Applications
Pronam Chatterjee, Staff Systems Engineer, VMware
Email: [email protected]
Twitter: pronamc