messaging for modern applications

33
1 CONFIDENTIAL 1 CONFIDENTIAL Taking the next step shouldn’t be scary … Messaging for Modern Applications

Upload: pronam-chatterjee

Post on 08-May-2015

810 views

Category:

Technology


3 download

TRANSCRIPT

Page 1: Messaging for modern applications

1CONFIDENTIAL 1CONFIDENTIAL

Taking the next step shouldn’t be scary …

Messaging for Modern Applications

Page 2: 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

Page 3: Messaging for modern applications

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

Page 4: Messaging for modern applications

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

Page 5: Messaging for modern applications

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

Page 6: Messaging for modern applications

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

Page 7: Messaging for modern applications

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

Page 8: Messaging for modern applications

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

Page 9: Messaging for modern applications

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

Page 10: Messaging for modern applications

10CONFIDENTIAL 10CONFIDENTIAL

Spring Integration

Page 11: Messaging for modern applications

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

Page 12: Messaging for modern applications

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.

Page 13: Messaging for modern applications

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.

Page 14: Messaging for modern applications

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.

Page 15: Messaging for modern applications

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.

Page 16: Messaging for modern applications

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.

Page 17: Messaging for modern applications

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” />

Page 18: Messaging for modern applications

18CONFIDENTIAL 18CONFIDENTIAL

Advanced Message Queuing Protocol

(AMQP)

Page 19: Messaging for modern applications

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

Page 20: Messaging for modern applications

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

Page 21: Messaging for modern applications

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

Page 22: Messaging for modern applications

22CONFIDENTIAL 22CONFIDENTIAL

AMQP Architecture

new.order

queue

M3M1 M2new.order

binding

new.order

routing key

Page 23: Messaging for modern applications

23CONFIDENTIAL 23CONFIDENTIAL

AMQP Architecture

café NA deliveries

queue

café deliveries

queue

M3M1 M2

M3M1 M2

café WW deliveries

queue

M3M1 M2

Page 24: Messaging for modern applications

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

Page 25: Messaging for modern applications

25CONFIDENTIAL 25CONFIDENTIAL

RabbitMQ

Page 26: Messaging for modern applications

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

Page 27: Messaging for modern applications

27CONFIDENTIAL 27CONFIDENTIAL

RabbitMQ – Messaging that Just Works

design goal: no bloat - “it just works”

mission: “be everywhere”

AMQP LEADER

Page 28: Messaging for modern applications

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

Page 29: Messaging for modern applications

29CONFIDENTIAL 29CONFIDENTIAL

Enterprise Users, such as this Tier-1 Telco

Page 30: Messaging for modern applications

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

Page 31: Messaging for modern applications

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

Page 32: Messaging for modern applications

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

Page 33: 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