Many businesses are faced with some new messaging challenges for modern applications, such as horizontal scalability of the messaging tier, heterogeneous messaging systems and access methods, and extreme transaction processing. This presentation/demo will cover how businesses can overcome these messaging challenges with the use of Spring and RabbitMQ technologies. Tom will build a case for AMQP, explain how SpringSource is providing AMQP support via Spring AMQP and Spring Integration, explain how RabbitMQ is a modern messaging solution that offers a reliable, highly available, scalable and portable messaging system with predictable and consistent throughput and latency, and demonstrate how Spring Integration and RabbitMQ can be progressively introduced into a standard Spring web application deployed on Cloud Foundry.
3. 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
4. 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
5. Modern Applications need Modern Messaging
Traditional approaches to messaging
imply predictable, static interaction
between well-known end-points
Modern approaches to messaging
embrace the unpredictable, dynamic,
and transient nature of the web
6. Synchronous Architecture is Brittle
An exception
occurred, Manage
please resend Inventory
Place Fulfill
Order Order
X
X
X X X
X X
X
X
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
7. Asynchronous Architecture Rules the Web
The status of
your order is I can fulfill
… part of
that Order
I have an
Order
I can fulfill
part of
Your order will that Order
be delivered
next Tuesday
I’ll schedule
delivery of
that order
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
8. How is Messaging Used within Modern Apps?
§ Event
I 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
8
9. 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.
9
10. 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.
10
11. 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.
11
12. 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, the Aggregator
publishes a single message distilled from the individual messages.
12
13. 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.
13
14. Modularity
Deploy, Scale, Version a distributed system
Local Distributed
<service-activator <int-amqp:outbound-gateway
input-channel="coldDrinks” id="coldDrinksBarista"
ref="barista” request-channel="coldDrinks”
method="prepareColdDrink” reply-channel="preparedDrinks”
output-channel="preparedDrinks” /> routing-key="ordered.drinks.cold” />
<service-activator <int-amqp:outbound-gateway
input-channel="hotDrinks” id="hotDrinksBarista"
ref="barista" request-channel="hotDrinks”
method="prepareHotDrink" reply-channel="preparedDrinks”
output-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.
14
16. Advanced Message Queuing Protocol
“Like
email,
but
you
can
send
money
over
it”
Open,
Ubiquitous,
and
Adaptable
async SMTP AMQP
sync HTTP IIOP
unreliable reliable
16
17. 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
rou>ne
*
• The
NIC
is
usually
the
boDleneck
*
Non-‐persistent
messages
17
18. 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
18
22. Demo – Scaling the Café Demo
with AMQP in Cloud Foundry
22
23. Legacy Middleware not suited for Modern Apps
Apps &
Middleware Existing middleware impacts agility by tightly
coupling applications to underlying application
server and other middleware components
Costly to Scale Up Complex to Scale Out Licensed by Peak Physical Servers
23
24. RabbitMQ – Messaging that Just Works
design goal: no bloat - “it just works”
mission: “be everywhere”
AMQP LEADER
25. Incredible Community Lowers Your Cost of Use
!"##$%(0$.%-$#G%,0(#K(C4.%(@$/G9(%KE,(E8"i4-C.
!"##$%&'`j<>("/0(&$:-4.4R(2g7(E"-%/,-.+$E
A,(4^,-(E":T"?,.(F4-(C"/K(4%+,-(=Q(E8"i4-C.
;84G0("/0(WG$80H!G/H&"/"?,(*$88(0-$3,(C4-,(."8,.
28. Enterprise Features, such as Fault Tolerance
ESX1
VM1 VM2
RMQ1 RMQ2
hot-drinks hot-drinks
cold-drinks cold-drinks
master
slave
29. Our New Mission: “It’s Just There”
Java App Private Cloud Hybrid Cloud
vFabric Cloud Foundry vFabric Cloud Foundry
Ruby App vSphere vSphere
Downloadable
Micro Cloud
1. Build your messaging application
vFabric Cloud Foundry
2. Deploy it, Scale it using Messaging Service Service
Provider
3. Move on or off premise as needed
31. Demo – Deploying the Café Demo
with RabbitMQ in a Hybrid Cloud
31
32. 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