eip flashcards
TRANSCRIPT
![Page 1: EIP Flashcards](https://reader035.vdocuments.us/reader035/viewer/2022073013/540d71237bef0aff298b48af/html5/thumbnails/1.jpg)
Get the tool: fusesource.com/IDE
Apache Camel is a popular open source integrati on framework that makes
it easy for developers to implement Enterprise Integrati on Patt erns.
htt p://camel.apache.org
Get the tool: fusesource.com/IDE
The design patt erns defi ned in this deck
are based on the book Enterprise Integrati on
Patt erns (Addison-Wesley). Gregor Hohpe
and Bobby Woolf documented their
combined experience in the integrati on space and
created this notati on, which has since been
adopted as the standard for describing
messaging soluti onswww.eaipatt erns.com
Get the tool: fusesource.com/IDE
Use Messaging to transfer packets of data frequently, immediately, reliably, and
asynchronously, using customizable formats.
Messaging
Message Bus
ApplicationA
ApplicationA
ApplicationB
ApplicationB
ApplicationC
ApplicationC
Event
Get the tool: fusesource.com/IDE
Connect the applicati ons using a Message Channel, where one
applicati on writes informati on to the channel and the other one
reads that informati on from the channel.
Message Channel
Sender Application
Messaging System
Receiver Application
Message Channel
Get the tool: fusesource.com/IDE
Package the informati on into a Message, a data record that the messaging system can transmit
through a Message Channel.
Message
Message Bus
ApplicationA
ApplicationA
ApplicationB
ApplicationB
ApplicationC
ApplicationC
Event
Get the tool: fusesource.com/IDE
Develop each applicati on as a large-scale object or component with encapsulated data. Provide
an interface to allow other applicati ons to interact with the
running applicati on.
Remote Procedure Invocati on
FunctionApplication
A
Application
A
Application
B
Application
BResult
Stub
Stub
Skeleton
Skeleton
Get the tool: fusesource.com/IDE
Integrate applicati ons by having them store their data in a single
Shared Database, and defi ne the schema of the database
to handle all the needs of the diff erent applicati ons.
Shared Database
ApplicationA
ApplicationA
SharedData
ApplicationB
ApplicationB
ApplicationC
ApplicationC
File Transfer
Have each applicati on produce fi les that contain the informati on
the other applicati ons must consume. Integrators take the responsibility of transforming
fi les into diff erent formats. Produce the fi les at regular
intervals according to the nature of the business.
Application
A
Application
A
Application
B
Application
B
Export
Export
Import
ImportShared
Data
�
Get the tool: fusesource.com/IDE
Get the tool: fusesource.com/IDE
Pipes and Filters describes a fundamental architectural style
for messaging systems:Individual processing steps
(fi lters) are chained together through the messaging channels
(pipes).
Pipes and Filters
IncomingOrder
AuthenticateAuthenticateDecryptDecrypt De-DupDe-Dupe
CleanOrder
Filter Filter Filter
PipePipePipe Pipe
![Page 2: EIP Flashcards](https://reader035.vdocuments.us/reader035/viewer/2022073013/540d71237bef0aff298b48af/html5/thumbnails/2.jpg)
Get the tool: fusesource.com/IDE
Use a special fi lter, a Message Translator, between other fi lters or applicati ons to translate one
data format into another.
Message Translator
Translator
Incoming Message Translated Message
Get the tool: fusesource.com/IDE
Insert a special fi lter, a Message Router, which consumes a
Message from one Message Channel and republishes it to a diff erent Message Channel,
depending on a set of conditi ons.
Message Router
MessageRouter
outQueue 1
outQueue 2
inQueue
Get the tool: fusesource.com/IDE
When a messaging system determines that it cannot or
should not deliver a message, it may elect to move the message
to a Dead Lett er Channel.
Dead Lett erChannel
ChannelSender Intended Receiver
Dead Letter Channel
Message
Dead Message
Delivery Fails
Reroute Delivery
Get the tool: fusesource.com/IDE
The messaging system uses local datastores to persist messages. A send operati on cannot complete
successfully unti l the message is stored in the sender’s local
datastore. A message cannot be deleted from one datastore unti l it is forwarded and stored in the
next datastore.
Guaranteed Delivery
Sender Receiver
Disk Disk
Computer 2Computer 1
Get the tool: fusesource.com/IDE
A Message Bus is a combinati on of a Canonical Data Model, a common command set, and a messaging infrastructure
to allow diff erent systems to communicate through a shared
set of interfaces.
Message Bus
Application
Application
ApplicationMessage Bus
Get the tool: fusesource.com/IDE
Send the event on a Publish-Subscribe Channel, which
delivers a copy of a parti cular event to each receiver.
Publish-Subscribe Channel
Publisher SubscriberAddress Changed
Address Changed
SubscriberAddress Changed
SubscriberAddress Changed
Publish-Subscribe Channel
Get the tool: fusesource.com/IDE
A Point-to-Point Channel ensures that only one receiver consumes any given message. The channel can have multi ple receivers that can consume multi ple messages
concurrently, but only one of them can successfully consume a
parti cular message.
Point-to-Point Channel
Sender ReceiverOrder #3
Order #2
Order #1
Order #3
Order #2
Order #1
Point-to-Point Channel
Get the tool: fusesource.com/IDE
The Message Endpoint encapsulates the messaging system from the rest of the
applicati on and customizes a general messaging API for a specifi c applicati on and task.
Message Endpoint
Sender Application
Receiver Application
ChannelMessage
Data DataMessage Endpoint
Message Endpoint
Get the tool: fusesource.com/IDE
Use a Command Message to reliably invoke a procedure in
another applicati on.
Command Message
Sender ReceiverCommand Message
CCC
= getLastTradePrice('DIS');C
![Page 3: EIP Flashcards](https://reader035.vdocuments.us/reader035/viewer/2022073013/540d71237bef0aff298b48af/html5/thumbnails/3.jpg)
Get the tool: fusesource.com/IDE
Use an Event Message for reliable, asynchronous
event noti fi cati on between applicati ons.
Event Message
Observer
E
Observer
E
Observer
E
Event Message
E
Subject
E
= aPriceChangedEventE
Get the tool: fusesource.com/IDE
A Document Message just passes data and lets the receiver decide what, if anything, to do with the
data. The data is a single unit of data, a single object or data structure that may decompose
into smaller units.
Document Message
Sender ReceiverDocument Message
DDD
= aPurchaseOrderD
Get the tool: fusesource.com/IDE
The Content-Based Router examines the message content and routes the message onto a diff erent channel based on data
contained in the message.
Content-Based Router
RouterNew Order
WidgetInventory
GadgetInventory
Get the tool: fusesource.com/IDE
The Message Filter is a Message Router with a single output channel. If the content of an incoming message matches the criteria specifi ed by the
Message Filter, the message is routed to the output channel. If the message content does not
match the criteria, the message is discarded.
Message Filter
MessageFilter
WidgetQuote
GadgetQuote
WidgetQuote
WidgetQuote
WidgetQuote
Get the tool: fusesource.com/IDE
The Dynamic Router routes messages using a rule base that
is generated based on input from potenti al message recipients.
Communicati on between recipients and the router are done over a special control
channel.
Dynamic Router
Control Channel
Message Router
Dynamic Rule Base
AA
BB
CC
Input Channel
Output Channel
Output Channel
Output Channel
Dynamic Router
Get the tool: fusesource.com/IDE
A requestor assigns each request with a unique request ID.
Replier’s add the request ID to the reply so that the requestor can correlate the reply with the
request that generated it.
Correlati on Identi fi er
Requestor Replier
Requests
Replies
3 2 1
1 2 3
1
1
Message ID
Correlation ID
Correlation
Get the tool: fusesource.com/IDE
A message’s Return Address is analogous to the reply-to fi eld in an e-mail message. The reply-to
e-mail address is usually the same as the from address, but
the sender can set it to a diff erent address to receive replies in an
account other than the one used to send the original message.
Return Address
Requestor 1 Replier
Requestor 2
Reply Channel 1
Reply Channel 2
Request Channel
Reply Channel 1
Reply Channel 2
Reply
Reply
Requests
Get the tool: fusesource.com/IDE
Request-Reply has two parti cipants:
1. Requestor sends a request message and waits for a reply
message.
2. Replier receives the request message and responds with a
reply message.
Request-Reply
Request RequestChannel
ReplyChannel
ReplyRequestor Replier
Get the tool: fusesource.com/IDE
Defi ne a channel for each recipient. Then use a Recipient
List to inspect an incoming message, determine the list of desired recipients, and forward
the message to all channels associated with the recipients in
the list.
Recipient List
Recipient List
AA
BB
CC
DD
Recipient Channel
![Page 4: EIP Flashcards](https://reader035.vdocuments.us/reader035/viewer/2022073013/540d71237bef0aff298b48af/html5/thumbnails/4.jpg)
Get the tool: fusesource.com/IDE
Use a stateful fi lter, an Aggregator, to collect and store
individual messages unti l it receives a complete set of related messages. Then, the Aggregator
publishes a single message disti lled from the individual
messages.
Aggregator
AggregatorInventory
Order
InventoryItem 1
InventoryItem 2
InventoryItem 3
Get the tool: fusesource.com/IDE
Use a Splitt er to break out the composite message into a series
of individual messages, each containing data related to one
item.
Splitt er
SplitterNew OrderOrderItem 1
OrderItem 2
OrderItem 3
Get the tool: fusesource.com/IDE
Att ach a Routi ng Slip to each message, specifying the
sequence of processing steps. Wrap each component with a
special message router that reads the Routi ng Slip and routes the
message to the next component in the list.
Routi ng Slip
AC
Proc AProc A
Proc BProc B
Proc CProc C
Attach Routing Slip to Message
Route MessageAccording to Slip
Get the tool: fusesource.com/IDE
The Content Enricher uses informati on inside the incoming
message (e.g., key fi elds) to retrieve data from an external
source. Aft er the Content Enricher retrieves the required
data from the resource, it appends the data to the
message.
Content EnricherEnricher
Basic Message Enriched Message
Resource
Get the tool: fusesource.com/IDE
Use a Content Filter to remove unimportant data items from a
message, leaving only important items.
Content Filter
Content Filter
Message Message
�
Get the tool: fusesource.com/IDE
Use a Scatt er-Gather that broadcasts a message to multi ple recipients and reaggregates the
responses back into a single message.
Scatt er-Gather
Quote Request
Vendor AVendor A
Vendor BVendor BBroadcast
Quote
Aggregator“Best” Quote
Vendor CVendor C
Get the tool: fusesource.com/IDE
Use a Composed Message Processor to process a composite
message. The Composed Message Processor splits
the message up, routes the submessages to the appropriate desti nati ons, and reaggregates
the responses back into a single message.
Composed Message Processor
New Order ValidatedOrder
CompositeMessageProcessor
Get the tool: fusesource.com/IDE
The Resequencer can receive a stream of messages that may not
arrive in order. It stores out-of-sequence messages in an internal buff er unti l a complete sequence is obtained, and then publishes
the messages to the output channel in the proper sequence.
Resequencer
Resequencer
1
3
2 13 2
Get the tool: fusesource.com/IDE
Store message data in a persistent store and pass a Claim Check to subsequent
components. These components can use the Claim Check to
retrieve the stored informati on.
Claim CheckCheck Luggage
Messagew/Data
Message w/Claim Check
Datastore
Data Enricher
Messagew/Data
![Page 5: EIP Flashcards](https://reader035.vdocuments.us/reader035/viewer/2022073013/540d71237bef0aff298b48af/html5/thumbnails/5.jpg)
Get the tool: fusesource.com/IDE
The Messaging Gateway encapsulates messaging-specifi c code (e.g., the code required to send or receive a message) and separates it from the rest of the
applicati on code.
Messaging Gateway
Messaging System
Application
Messaging Gateway
Application
Messaging Gateway
Get the tool: fusesource.com/IDE
The Normalizer features one Message Translator for each message format and routes
the incoming message to the correct Message Translator via a
Message Router.
Normalizer
Router
Normalizer
Common FormatDifferent MessageFormats
Translators
Get the tool: fusesource.com/IDE
An Event-Driven Consumer is an object that is invoked by the messaging system
when a message arrives on the consumer’s channel. The
consumer passes the message to the applicati on through a
callback in the applicati on’s API.
Event-Driven Consumer
Sender
Receiver
Message Event-Driven Consumer
Get the tool: fusesource.com/IDE
Competi ng Consumers are multi ple consumers that are all
created to receive messages from a single Point-to-Point Channel.
When the channel delivers a message, any of the consumers
could potenti ally receive it.
Competi ng Consumers
Sender Consumer
Consumer
Consumer
1
Messages
23
1
2
3
Receiver
Receiver
Get the tool: fusesource.com/IDE
When a Message Dispatcher receives a message, it obtains a performer and dispatches the message to the performer to
process it.
Message Dispatcher
Receiver
Sender PerformerMessage Dispatcher
Performer
Performer
1
Messages
23
1
2
3
Get the tool: fusesource.com/IDE
A Polling Consumer is an object that an applicati on uses to
receive messages by explicitly requesti ng them. When the
applicati on is ready for another message, it polls the consumer,
which in turn gets a message from the messaging system and
returns it.
Polling Consumer
Sender Message
Receiver
Polling Consumer
Get the tool: fusesource.com/IDE
Use a Transacti onal Client—make the client’s session with the
messaging system transacti onal so that the client can specify
transacti on boundaries.
Transacti onal Client
Transactional Consumer
Receiver
MessageTransactional Producer
Sender
transaction transaction
Get the tool: fusesource.com/IDE
The Messaging Mapper accesses one or more domain objects and
converts them into a message as required by the messaging channel. It also performs the opposite functi on, creati ng or
updati ng domain objects based on incoming messages.
Messaging Mapper
BusinessObject
MessagingInfrastructure
MessagingMapper
Get the tool: fusesource.com/IDE
When a message arrives, a Selecti ve Consumer tests the message’s selecti on value to
see if the value meets the consumer’s selecti on criteria. If so, the consumer receives the message and passes it to the
applicati on for processing.
Selecti ve Consumer
Specifying Producer
Receiver
Messages with Selection Values
Selective Consumer
![Page 6: EIP Flashcards](https://reader035.vdocuments.us/reader035/viewer/2022073013/540d71237bef0aff298b48af/html5/thumbnails/6.jpg)
Get the tool: fusesource.com/IDE
Design a receiver to be an Idempotent Receiver, one that
can safely receive the same message multi ple ti mes.
Idempotent Receiver
Sender ReceiverMessage
Message
Ack.
Ack.
Network Failure
Duplicate Message
Get the tool: fusesource.com/IDE
Use a Durable Subscriber to make the messaging system save
messages published while the subscriber is disconnected.
Durable Subscriber
Publisher
Durable Subscriber
Non-Durable Subscriber
Publish-Subscribe Channel
Receiver
Receiver
Get the tool: fusesource.com/IDE
Use a Message Store to capture informati on about each message
in a central locati on.
Message Store
Message Store
Get the tool: fusesource.com/IDE
The Wire Tap (also known as tee) is a fi xed Recipient List with two
output channels. It consumes messages off the input channel and publishes the unmodifi ed
message to both output channels.
Wire Tap
DestinationDestinationSourceSource
Wire Tap
Get the tool: fusesource.com/IDE
Construct a Detour with a Context-Based Router controlled via the Control Bus. In one state,
the router routes incoming messages through additi onal
steps, while in the other it routes messages directly to the
desti nati on channel.
Detour
DestinationDestinationSourceSourceDetour
Control
Get the tool: fusesource.com/IDE
A Service Acti vator handles all of the messaging details and
invokes the service like any other client, such that the service doesn’t even know it’s being invoked through messaging.
Service Acti vator
Replier
Service Activator
Request
Reply
Service
Requestor
Get the tool: fusesource.com/IDE
FuseSource is the leader in open source integrati on
and messaging, and off ers distributi ons of Apache projects that are producti zed and
supported by the people who wrote the code.
Please visit
fusesource.com