Spring Integration and EIP Introduction

39
Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. Spring Integration Connecting Enterprise Applications

description

Positions Spring Integration in a messaging architecture and compares with a few others. Also glances over some enterprise integration patterns.With the presentation are a lot of live demo's, so it might not make sense in isolation.

Transcript of Spring Integration and EIP Introduction

Page 1: Spring Integration and EIP Introduction

Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited.

Spring Integration

Connecting Enterprise Applications

Page 2: Spring Integration and EIP Introduction

2Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 2

Topics in this session

• Introduction to Spring Integration• Spring Integration Compared• Enterprise Integration Patterns• Examples and demos• Summary and questions

Page 3: Spring Integration and EIP Introduction

3Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 3

The synchronous breakdown

• A customer orders a coffee– and waits

• The waiter walks to the barista and passes the order– and waits

• The barista walks to the coffee machine– and waits

• How about the next customer?

Page 4: Spring Integration and EIP Introduction

4Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 4

What is Messaging?

How can multiple agents work together?...

...without being in each others way.

Waiter helps customer and cook to collaborate.

Page 5: Spring Integration and EIP Introduction

5Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 5

Characteristics of Messaging

TransportThe waiter takes an order and moves it to the barista

AsynchronousDifferent actors do different things in parallel

Translationmenu item => number => recipe

RoutingOrders arrive back at the proper table

Page 6: Spring Integration and EIP Introduction

6Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 6

Why messaging (1/4)

Loose coupling

Page 7: Spring Integration and EIP Introduction

7Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 7

Why Messaging? (2/4)

Performance

Page 8: Spring Integration and EIP Introduction

8Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 8

Why Messaging? (3/4)

Flexibility

Page 9: Spring Integration and EIP Introduction

9Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 9

Why Messaging? (4/4)

Interception and filtering

Page 10: Spring Integration and EIP Introduction

10Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 10

Spring Integration

Page 11: Spring Integration and EIP Introduction

11Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 11

Hello world

<service-activator input-channel="inputChannel" default-output-channel="outputChannel" ref="helloService" method="sayHello"/>

<beans:bean id="helloService" class="...HelloService"/>

public class HelloService { public String sayHello(String name) { return "Hello " + name; }}

Page 12: Spring Integration and EIP Introduction

12Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 12

Hello world

inputChannel = context.getBean("inputChannel");

outputChannel = context.getBean("outputChannel");

inputChannel.send(new StringMessage("World"));System.out.println(

outputChannel.receive().getPayload());

$ java HelloWorldDemoHello World

Page 13: Spring Integration and EIP Introduction

13Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 13

Channels

<channel id="incoming"/>

<channel id="orderedNotifications"> <queue capacity="10"/></channel>

Page 14: Spring Integration and EIP Introduction

14Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 14

Channels

Page 15: Spring Integration and EIP Introduction

15Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 15

MessageEndpoints

SenderApplication

ReceiverApplication

Channel

MessageEndpoint

MessageEndpoints are the knots that tie applications to the integration solution.

Page 16: Spring Integration and EIP Introduction

16Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 16

Missing link

SenderApplication

ReceiverApplication

Channel

Invoked by Sender Who is responsible?

Page 17: Spring Integration and EIP Introduction

17Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 17

The Poller

<poller default="true"/>In Spring Integration:

you don't need to worry about it

A Message Bus enables separate applications to work together, but in a decoupled fashion such that applications can be easily added or removed without affecting the others.

Page 18: Spring Integration and EIP Introduction

18Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 18

Topics in this session

• Introduction to Spring Integration• Comparing Spring Integration to others• Enterprise Integration Patterns• Examples and demos• Summary and questions

Page 19: Spring Integration and EIP Introduction

19Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 19

What’s different about Spring Integration?

• Can be used from within an existing application.

• Lightweight (like any Spring application):– run from JUnit test– run within webapp

• Focussed on messaging and integration• Not an ESB

Page 20: Spring Integration and EIP Introduction

20Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 20

Others in general

• Full blown ESB• It’s an application, not a framework

– You need to install it – You need to run it

• Typically a lot heavier• Focus on the deployment architecture

not the actual integration.

Page 21: Spring Integration and EIP Introduction

21Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 21

Mule

• Integrates with Spring• Lots of integration options:

– REST, SOAP– JMS

• Embeddable• Distribution

– 32Mb– 2Mb jar only (for embedding)

Page 22: Spring Integration and EIP Introduction

22Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 22

ServiceMix

• Based on JBI – (Mediated Message Exchange Model)

• Distribution:– 100mb

• http://servicemix.apache.org/how-to-evaluate-an-esb.html

Page 23: Spring Integration and EIP Introduction

23Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 23

Camel

• Most direct competition for Spring Integration

• Less consistent with Spring• Focus on routing• Fluent interface as an alternative to xml

Page 24: Spring Integration and EIP Introduction

24Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 24

Considerations

• Routing complexity– a bus can be useful for more complex

routing problems

• Comfort zone– what will the developers feel at home with

• Keep it clean– don’t scatter the routing rules

Page 25: Spring Integration and EIP Introduction

25Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited.

25

Basic Integration

Page 26: Spring Integration and EIP Introduction

26Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited.

26

With a bus

Page 27: Spring Integration and EIP Introduction

27Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 27

Topics in this session

• Introduction to Spring Integration• Comparing Spring Integration to others• Enterprise Integration Patterns• Examples and demos• Summary and questions

Page 28: Spring Integration and EIP Introduction

28Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 28

Message Router

• Takes messages from a channel and forwards them to different channels

Page 29: Spring Integration and EIP Introduction

29Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 29

Competing Consumers

• Multiple consumers take messages from the channel

• First come first serve

Page 30: Spring Integration and EIP Introduction

30Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 30

Competing Consumers

Page 31: Spring Integration and EIP Introduction

31Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 31

Selective Consumer

• Select only relevant messages• Reduces the need for dedicated

channels

Page 32: Spring Integration and EIP Introduction

32Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 32

Selective Consumer

Page 33: Spring Integration and EIP Introduction

33Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 33

Splitter

Page 34: Spring Integration and EIP Introduction

34Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 34

Detour

Page 35: Spring Integration and EIP Introduction

35Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 35

Topics in this session

• Introduction to Spring Integration• Comparing Spring Integration to others• Enterprise Integration Patterns• Examples and demos• Summary and questions

Page 36: Spring Integration and EIP Introduction

36Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 36

Demo Time

Page 37: Spring Integration and EIP Introduction

37Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 37

Topics in this session

• Introduction to Spring Integration• Comparing Spring Integration to others• Enterprise Integration Patterns• Examples and demos• Summary and questions

Page 38: Spring Integration and EIP Introduction

38Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 38

Summary

• Spring Integration– works from existing Spring applications– lightweight– decentralized (if you want)

• Enterprise Integration Patterns– describe ways of plumbing the enterprise

application landscape.

Page 39: Spring Integration and EIP Introduction

39Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 39

Questions and Plugs

• You can ask questions now while you ignore these shameless plugs

• Thanks to Babiche Israel (cartoons)– http://babicheisrael.blogspot.com/

• Come to Java meetup May 23– http://tinyurl.com/66hfnt or– Google for ‘java meetup q2 2008’