Russell spring one2gx_messaging_india
-
Upload
garyprussell -
Category
Documents
-
view
233 -
download
1
Transcript of Russell spring one2gx_messaging_india
![Page 1: Russell spring one2gx_messaging_india](https://reader038.fdocuments.in/reader038/viewer/2022103115/557a6079d8b42a6e5a8b5213/html5/thumbnails/1.jpg)
Addressing Messaging Challenges Using Spring and RabbitMQ
© 2012 SpringOne 2GX. All rights reserved. Do not distribute without permission.
Gary Russell, Staff Engineer, SpringSource; @gprussell
![Page 2: Russell spring one2gx_messaging_india](https://reader038.fdocuments.in/reader038/viewer/2022103115/557a6079d8b42a6e5a8b5213/html5/thumbnails/2.jpg)
Addressing Messaging Challenges
• Modern Application Trends • Modularize with Spring Integration • Distribute with AMQP • Analyze with Hadoop
2
![Page 3: Russell spring one2gx_messaging_india](https://reader038.fdocuments.in/reader038/viewer/2022103115/557a6079d8b42a6e5a8b5213/html5/thumbnails/3.jpg)
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
X X
X X
X X
X X
X
An exception occurred,
please resend
Synchronous Architecture is Brittle
3
![Page 4: Russell spring one2gx_messaging_india](https://reader038.fdocuments.in/reader038/viewer/2022103115/557a6079d8b42a6e5a8b5213/html5/thumbnails/4.jpg)
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
Order Your order will be delivered next Tuesday
The status of your order is
…
Asynchronous Architecture Rules the Web
4
![Page 5: Russell spring one2gx_messaging_india](https://reader038.fdocuments.in/reader038/viewer/2022103115/557a6079d8b42a6e5a8b5213/html5/thumbnails/5.jpg)
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
Modern Applications Need Modern Messaging
5
![Page 6: Russell spring one2gx_messaging_india](https://reader038.fdocuments.in/reader038/viewer/2022103115/557a6079d8b42a6e5a8b5213/html5/thumbnails/6.jpg)
Modularize with Spring Integration
![Page 7: Russell spring one2gx_messaging_india](https://reader038.fdocuments.in/reader038/viewer/2022103115/557a6079d8b42a6e5a8b5213/html5/thumbnails/7.jpg)
• At the core, an embedded Message Bus – Inspired by Gregor Hohpe and Bobby Woolf's Enterprise
Integration Patterns (2003) – 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
What is Spring Integration?
7
![Page 8: Russell spring one2gx_messaging_india](https://reader038.fdocuments.in/reader038/viewer/2022103115/557a6079d8b42a6e5a8b5213/html5/thumbnails/8.jpg)
cafe
orders drinks
coldDrinks
hotDrinks
preparedDrinks deliveries
CafeDemoApp
Spring Integration Cafe
8
![Page 9: Russell spring one2gx_messaging_india](https://reader038.fdocuments.in/reader038/viewer/2022103115/557a6079d8b42a6e5a8b5213/html5/thumbnails/9.jpg)
Café
http
Spring Integration Café – Simple HTTP Deployment
9
![Page 10: Russell spring one2gx_messaging_india](https://reader038.fdocuments.in/reader038/viewer/2022103115/557a6079d8b42a6e5a8b5213/html5/thumbnails/10.jpg)
Distribute with AMQP
10
![Page 11: Russell spring one2gx_messaging_india](https://reader038.fdocuments.in/reader038/viewer/2022103115/557a6079d8b42a6e5a8b5213/html5/thumbnails/11.jpg)
A Protocol, not an API • A defined set of messaging
capabili2es 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 boFleneck
* Non-‐persistent messages
Why AMQP?
11
![Page 12: Russell spring one2gx_messaging_india](https://reader038.fdocuments.in/reader038/viewer/2022103115/557a6079d8b42a6e5a8b5213/html5/thumbnails/12.jpg)
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
Why AMQP?
12
![Page 13: Russell spring one2gx_messaging_india](https://reader038.fdocuments.in/reader038/viewer/2022103115/557a6079d8b42a6e5a8b5213/html5/thumbnails/13.jpg)
new.order
queue
M3 M1 M2 new.order binding
new.order routing key
AMQP Architecture
13
![Page 14: Russell spring one2gx_messaging_india](https://reader038.fdocuments.in/reader038/viewer/2022103115/557a6079d8b42a6e5a8b5213/html5/thumbnails/14.jpg)
café NA deliveries
queue
café deliveries
queue
M3 M1 M2
M3 M1 M2
café WW deliveries
queue
M3 M1 M2
AMQP Architecture
14
![Page 15: Russell spring one2gx_messaging_india](https://reader038.fdocuments.in/reader038/viewer/2022103115/557a6079d8b42a6e5a8b5213/html5/thumbnails/15.jpg)
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
AMQP Architecture
15
![Page 16: Russell spring one2gx_messaging_india](https://reader038.fdocuments.in/reader038/viewer/2022103115/557a6079d8b42a6e5a8b5213/html5/thumbnails/16.jpg)
Spring-AMQP
• AMQP core abstraction plus RabbitMQ implementation (built on rabbit client libraries)
• Higher level patterns for clients: admin, producers and consumers – RabbitAdmin – declare exchanges, queues, bindings – RabbitTemplate – convenience methods for send and receive – MessageListenerContainer – POJO message handler, asynchronous
• Spring Integration support
http://www.springsource.org/spring-amqp
16
![Page 17: Russell spring one2gx_messaging_india](https://reader038.fdocuments.in/reader038/viewer/2022103115/557a6079d8b42a6e5a8b5213/html5/thumbnails/17.jpg)
Spring-AMQP – What’s New (1.1.x)
• Support for HA Queues – Broker Failover
• Publisher Confirms – Callback when the message is secured in the broker
• Publisher Returns – Callback if message cannot be deposited in at least one queue
• Explicit Reply Queue – Avoids creation of temporary queue for request/reply scenarios
• Dead Letter Exchange/Queue Support
17
![Page 18: Russell spring one2gx_messaging_india](https://reader038.fdocuments.in/reader038/viewer/2022103115/557a6079d8b42a6e5a8b5213/html5/thumbnails/18.jpg)
Demo – Distributing the Spring Integration Café Demo with AMQP
![Page 19: Russell spring one2gx_messaging_india](https://reader038.fdocuments.in/reader038/viewer/2022103115/557a6079d8b42a6e5a8b5213/html5/thumbnails/19.jpg)
Spring Integration Café – Distributed Deployment with AMQP
19
amqp
Café Ops Café Storefront
http
amqp
![Page 20: Russell spring one2gx_messaging_india](https://reader038.fdocuments.in/reader038/viewer/2022103115/557a6079d8b42a6e5a8b5213/html5/thumbnails/20.jpg)
Spring Integration Café – Distributed Deployment with Hadoop
CRM Data Marts ERP
hdfs
map reduce
unstructured event data
structured information EDW
20
amqp
Café Ops Café Storefront
http
amqp