0% found this document useful (0 votes)
56 views87 pages

Enterprise Integration With Spring Integration: Agim Emruli Springsource 8100

This document discusses how Spring Integration helps solve common enterprise integration challenges through messaging and event-driven architectures. It presents Spring Integration's architecture including message construction, channels, endpoints, transformers, routers, and channel adapters. Spring Integration builds on Spring's existing features and allows reuse of service layers while incrementally extending integration capabilities.

Uploaded by

Ketan Desai
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
56 views87 pages

Enterprise Integration With Spring Integration: Agim Emruli Springsource 8100

This document discusses how Spring Integration helps solve common enterprise integration challenges through messaging and event-driven architectures. It presents Spring Integration's architecture including message construction, channels, endpoints, transformers, routers, and channel adapters. Spring Integration builds on Spring's existing features and allows reuse of service layers while incrementally extending integration capabilities.

Uploaded by

Ketan Desai
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 87

Enterprise Integration with Spring Integration

Agim Emruli SpringSource 8100

Presentation Goal

Learn how Spring Integration helps to solve common Enterprise Integration challenges

Integration Challenges

System Failures

Intolerant Systems

Enterprise Integration Patterns

Pattern Catalog Overview


Message Construction Message Transformation Message Routing
Envelope Wrapper

Message

Request Reply

Message Translator

Message Router

Content Based Router

C Command Message Normalizer

Return Address

Content FIlter

Composed Message

Splitter

D Document Message A B Content Enricher Claim Check Process Manager Aggregator

Correlation ID

E Event Message Message Sequence Message FIlter

Recipient List

How does Spring help ?

Spring Big Picture

Dependency Injection

Aspect oriented Programming

Enterprise Service Abstraction

Inversion of Control

10

Focus on Business domain

11

Spring Powered Applications


Testable Robust

Application
Maintainable Flexible

Layered Architecture

12

Layered Architecture

12

Domain Objects

Layered Architecture

12

Domain Objects

Database

Email

Messaging

Layered Architecture

12

Domain Objects Infrastructure

Database

Email

Messaging

Layered Architecture

12

Data Access Infrastructure

Domain Objects

Database

Email

Messaging

Layered Architecture

12

Services Data Access Infrastructure

Domain Objects

Database

Email

Messaging

Layered Architecture
AOP

12

Services Data Access Infrastructure

Domain Objects

Database

Email

Messaging

13

Layered Architecture

Spring Application

13

Layered Architecture

MVC

Spring Application

13

Layered Architecture

MVC

RMI

Spring Application

13

Layered Architecture

Webservice

MVC

RMI

Spring Application

13

Layered Architecture

Batch Webservice MVC RMI

Spring Application

13

Layered Architecture

Batch Webservice MVC

JMS RMI

Spring Application

14

Event Driven Architecture

Framework

Event

Application

15

Spring JMS Support

<jms:listener-container transaction-manager="txManager"> <jms:listener ref="orderService" method="order" destination="queue.orders" response-destination="queue.confirmation"/> </jms:listener-container>

15

Spring JMS Support


<jms:listener-container transaction-manager="txManager"> <jms:listener ref="orderService" method="order" destination="queue.orders" response-destination="queue.confirmation"/> </jms:listener-container> public class OrderService { public OrderConfirmation order(Order o) {..} }

16

Introducing Spring Integration

17

Goals

18

Reuse Service Layer

19

Incremental Extension

20

Spring Integration Architecture

20

Spring Integration Architecture

Services

20

Spring Integration Architecture


Webservice

Services

20

Spring Integration Architecture


Webservice File

Services

20

Spring Integration Architecture


Webservice File

Services

20

Spring Integration Architecture


Webservice File

Transformer

Services

20

Spring Integration Architecture


Webservice File

Transformer Router

Services

21

Message Construction

22

Message Structure
Message Header Sequence Number Sequence Size Expiration Date Correlation Identifier Message Body
C Command Message D Document Message E Event Message

23

Message Interface

public interface Message<T> { MessageHeaders getHeaders(); T getPayload(); }

Message Headers

24

Message Headers
String value = headers.get("key", String.class); Object id = headers.getId(); Long timestamp = headers.getTimestamp(); MessagePriority priority = headers.getPriority();

24

MessageHeaders headers = message.getHeaders();

Message Builder

25

Message Builder
Message<String> message = MessageBuilder.withPayload("test") .setHeader("foo", 123) .setPriority(MessagePriority.HIGHEST) .build();

25

Message<String> copy = MessageBuilder.fromMessage(message) .setHeader("foo", 456) .setHeaderIfAbsent("bar", 789) .build();

Channels And Endpoints


26

27

Message Channel

Message

Message

Message Endpoint

Channel

Message Endpoint

28

Direct Channels

Message Endpoint

Channel

Event-Driven Consumer

28

Direct Channels

Message Endpoint

Channel

Event-Driven Consumer

<channel id="sync-p2p" />

29

Queue Channel

Message Endpoint

Channel

Polling Consumer

29

Queue Channel

Message Endpoint

Channel

Polling Consumer

<channel id="async-p2p"> <queue capacity="50" /> </channel>

30

Publish-Subscribe Channel

Event-Driven Consumer

Message Endpoint

Publish Subscribe Channel Event-Driven Consumer

30

Publish-Subscribe Channel
Event-Driven Consumer

Message Endpoint

Publish Subscribe Channel Event-Driven Consumer

<publish-subscribe-channel id="pubsub" />

31

Priority Channel

Message Endpoint

Channel

Polling Consumer

Resequencer

31

Priority Channel

Message Endpoint

Channel

Polling Consumer

Resequencer

<channel id="priorityChannel"> <priority-queue comparator="someComp" /> </channel>

Message Transformation

32

33

Message Translator

Channel

Message Translator

Channel

33

Message Translator

Channel

Message Translator

Channel

<transformer input-channel="input" output-channel="output" ref="transformer" method="transform"/>

34

Annotation Based Message Translator


@MessageEndpoint public class MessageTransformer{ @Transformer(inputChannel="in", outputChannel="out") public LoanRequest transform(Loan loan){ return ...; } }

Service Activator

35

36

Service Activator

Message Endpoint

Channel

Service Activator

Message Endpoint

Channel

37

Service Activator
<channel id="requests"/> <channel id="quotes"/> <service-activator input-channel="requests" ref="loanBroker" method="processRequest" output-channel="quotes"/> <beans:bean id="loanBroker" class="example.LoanBroker"/>

38

Annotation Based Service Activator


@MessageEndpoint public class LoanBroker { @ServiceActivator(inputChannel="x", outputChannel="y") public LoanQuote processRequest( LoanRequest request) { LoanQuote quote ...; return quote; } }

39

Polling and Transactions


<service-activator ref="loanBroker" method="processRequest" input-channel="requests" output-channel="quotes"> <poller task-executor="pool1"> <interval-trigger interval="5000"/> <transactional propagation="REQUIRES_NEW"/> </poller> </service-activator> <pool-executor id="pool1" max-size="25"/> <beans:bean id="transactionManager" ... />

Message Routing

40

41

Content Based Router

Standard Service Channel

Channel

Content Based Router

VIP Service Channel

42

MethodInvokingRouter
<channel id="even"/> <channel id="odd"/> <router ref="parityResolver" inputchannel="numbers"/>

42

MethodInvokingRouter
<channel id="even"/> <channel id="odd"/> <router ref="parityResolver" inputchannel="numbers"/> @Router public String getParity(int i) { return (i % 2 == 0) ? "even" : "odd"; }

43

PayloadtypeRouter

String Channel

Channel

Content Based Router

Integer Channel

43

PayloadtypeRouter
String Channel

Channel

Content Based Router

Integer Channel

typeMap .put(String.class, stringChannel); typeMap.put(Integer.class, integerChannel); PayloadTypeRouter router = new PayloadTypeRouter(); router.setPayloadTypeChannelMap(typeMap); router.handleMessage(new StringMessage("test")); router.handleMessage(new GenericMessage(123));

44

ReceipientListRouter

Channel

Channel

Recipient List

Channel

44

ReceipientListRouter
Channel Channel Recipient List

Channel

channels.add(channel1); channels.add(channel2); RecipientListRouter router = new RecipientListRouter(); router.setChannels(channels); Message<String> message = new StringMessage("test"); router.handleMessage(message);

45

Splitter And Aggregator

Channel

Splitter

Aggregator

Channel

46

Splitter And Aggregator


@Splitter public List<OrderItem> splitOrder(PurchaseOrder order, @Header("customerId") String customerId) { // split the purchase order into order items }

46

Splitter And Aggregator


@Splitter public List<OrderItem> splitOrder(PurchaseOrder order, @Header("customerId") String customerId) { // split the purchase order into order items }

@Aggregator public PurchaseOrder aggregateOrder(List<OrderItem> items) { // aggregate the items into a single order object... }

Channel Adapter

47

48

Channel Adapters

Inbound
Message External System Channel Adapter Channel

48

Channel Adapters

Inbound
Message External System Channel Adapter Channel

Outbound
Message Channel Channel Adapter External System

49

File Adapter
<file:inbound-channel-adapter channel="filesIn" directory="${java.io.tmpdir}/test-input"> <poller max-messages-per-poll="5"> <cron-trigger expression="*/10 * * * * MON-FRI"/> </poller> </file:inbound-channel-adapter>

<file:outbound-channel-adapter channel="filesOut" directory="${java.io.tmpdir}/test-output"/>

50

JMS Adapter
<jms:inbound-channel-adapter channel="input" connection-factory="connectionFactory" destination-name="sourceQueueName"/> <jms:outbound-channel-adapter channel="output" destination="targetQueue"/> <jms:inbound-gateway request-channel="inRequests" destination="inboundRequestQueue"/> <jms:outbound-gateway request-channel="outRequests" reply-channel="replies" jms-queue="outQueue"/>

51

Method Invoking Adapter


<channel id="channel"/> <inbound-channel-adapter channel="channel" ref="reader" method="read"> <poller max-messages-per-poll="1"> <interval-trigger interval="1000"/> </poller> </inbound-channel-adapter> <outbound-channel-adapter channel="channel" ref="writer" method="write"/>

52

Webservice Adapter
<ws:outbound-gateway uri="http://..." marshaller="someMarshaller" unmarshaller="someMarshaller" request-channel="req" reply-channel="rep"/>

<ws:inbound-gateway request-channel="req" reply-channel="rep" marshaller="someMarshaller" unmarshaller="someMarshaller" />

53

Other Adapters

> HTTP > Mail > RMI > springsource.org/extensions

54

Q&A
Agim Emruli [email protected]

55

THANK YOU!

56

Picture Credits
http://www.flickr.com/photos/scraplab/2612334635/

http://www.flickr.com/photos/mylifestory/527847004/

http://www.flickr.com/photos/alex-s/116511016/

http://www.flickr.com/photos/jdan/2324469981/

57

Picture Credits
http://www.flickr.com/photos/global-jet/2125557004/

You might also like