SOA Atomic patternslogosworld.com/docs/soaindia/soaindia2008/Angeli_S... · Logosworld.com SOA City...
Transcript of SOA Atomic patternslogosworld.com/docs/soaindia/soaindia2008/Angeli_S... · Logosworld.com SOA City...
Logosworld.com
SOA City
Building SOA City by Lynton Grice Logosworld SOA India 17.Nov 2008 Bangalore
Building SOA CityAtomic SOA Patterns
Elementary Middleware Communication Patterns for a Succesful SOA ImplementationSOA India Certication Course – Part 1By Axel Angeli – SOA Evangelist - [email protected]
Logosworld.com
SOA City
Building SOA City by Lynton Grice Logosworld SOA India 17.Nov 2008 Bangalore
Any complex communication throughmiddleware can be efficiently built froma small number of atomic patterns
Atomic Communication PatternsEnhance Middleware Development Quality
Saturd
ay, 2
2 N
ov
emb
er 20
08 2
Axel A
ngeli -
(c) 20
08
logo
swo
rld.co
m -
Bu
ildin
g the SO
A C
ity
Logosworld.com
SOA City
Building SOA City by Lynton Grice Logosworld SOA India 17.Nov 2008 Bangalore
Communications is a three step process
Receive
Process
Send
Logosworld.com
SOA City
Building SOA City by Lynton Grice Logosworld SOA India 17.Nov 2008 Bangalore
Von Neumann Computers do The Same
János von Neumann zu Margitta
Father of modern computer architecture Input
Process
Output
János von Neumann zu MargittaFather of modern computer architecture
Logosworld.com
SOA City
Building SOA City by Lynton Grice Logosworld SOA India 17.Nov 2008 Bangalore
Logosworld.com
Canonical Data Transport
Saturd
ay, 2
2 N
ov
emb
er 20
08 5
Axel A
ngeli -
(c) 20
08
logo
swo
rld.co
m -
Bu
ildin
g the SO
A C
ity
As a pre-requisite make sure that dataexchange within a layer happens always
using a Canonical Format
Logosworld.com
SOA City
Building SOA City by Lynton Grice Logosworld SOA India 17.Nov 2008 Bangalore
Use separate technologies forInput/Output (=Adapters)Process Logic
Split development across layersOne developer for I/OOne developer for Process Logic
How can a project leader enforce component use and
segregation of duties?
Saturd
ay, 2
2 N
ov
emb
er 20
08 6
Axel A
ngeli -
(c) 20
08
logo
swo
rld.co
m -
Bu
ildin
g the SO
A C
ity
Logosworld.com
SOA City
Building SOA City by Lynton Grice Logosworld SOA India 17.Nov 2008 Bangalore
SOA Application Layer Model (non-OSI)
• Canonical Content representationContent
• HTML, XML, JSON, ASCIIEnvelope
• HTTP, FTP, WebDAV, SteganographieTransport
• TCP, UDP, IPXDelivery
• IPData Linkage
• Ethernet, Token-RingNetwork
• WLAN, Cable, Sound, File-SystemPhysical
Saturd
ay, 2
2 N
ov
emb
er 20
08 7
Axel A
ngeli -
(c) 20
08
logo
swo
rld.co
m -
Bu
ildin
g the SO
A C
ity
Logosworld.com
SOA City
Building SOA City by Lynton Grice Logosworld SOA India 17.Nov 2008 Bangalore
Example: How we copy a file
The quick & dirty approach
• Procedure CopyFile
• Read the input file
• Convert encoding
• Save the file
The atomic approach• Procedure readFile• Read the input file
• Procedure convertEncoding• Convert encoding
• Procedure saveFile• Save the file
• Procedure CopyFile• Call inputFile• Call convertEncoding• Call saveFile
Saturd
ay, 2
2 N
ov
emb
er 20
08 8
Axel Angeli - (c) 2008 logosworld.com - Building the SOA City
Logosworld.com
SOA City
Building SOA City by Lynton Grice Logosworld SOA India 17.Nov 2008 Bangalore
Data Transport in Envelopes
Canonical Format
• Internal container
Transport Envelope
• Protocol specific
• HTML, JSON, Text Physical Format
• Transport protocol
• HTTP, FTP, FileSys
Saturd
ay, 2
2 N
ov
emb
er 20
08 9
Axel A
ngeli -
(c) 20
08
logo
swo
rld.co
m -
Bu
ildin
g the SO
A C
ity
Logosworld.com
SOA City
Building SOA City by Lynton Grice Logosworld SOA India 17.Nov 2008 Bangalore
Conversion in Adapters
Physical Format Adapter
Transport envelope Adapter
Canonical Format Data ready for program
Saturd
ay, 2
2 N
ov
emb
er 20
08 10
Axel A
ngeli -
(c) 20
08
logo
swo
rld.co
m -
Bu
ildin
g the SO
A C
ity
Logosworld.com
SOA City
Building SOA City by Lynton Grice Logosworld SOA India 17.Nov 2008 Bangalore
Logosworld.com
Communication Categories
Saturd
ay, 2
2 N
ov
emb
er 20
08 11
Axel A
ngeli -
(c) 20
08
logo
swo
rld.co
m -
Bu
ildin
g the SO
A C
ity
Request & Response
Fire & Forget
Broadcast
Logosworld.com
SOA City
Building SOA City by Lynton Grice Logosworld SOA India 17.Nov 2008 Bangalore
Communication Categories
Request and Response
HTTP, FTP
Fire and Forget
Maildrop,Triggers
SMTP
Broadcast
MQ, Database, website
Saturd
ay, 2
2 N
ov
emb
er 20
08 12
Axel A
ngeli-
(c) 20
08
logo
swo
rld.co
m -
Bu
ildin
g the SO
A C
ity
Logosworld.com
SOA City
Building SOA City by Lynton Grice Logosworld SOA India 17.Nov 2008 Bangalore
Request and Response
• HTTP, FTP
Saturd
ay, 2
2 N
ov
emb
er 20
08 13
Axel A
ngeli-
(c) 20
08
logo
swo
rld.co
m -
Bu
ildin
g the SO
A C
ity
Client Server
Request
Response
Logosworld.com
SOA City
Building SOA City by Lynton Grice Logosworld SOA India 17.Nov 2008 Bangalore
Fire and Forget
• Sender does not accept a response• Mail drop; Message Queue
• SMTP
• Infrastructure can supervise the delivery
Saturd
ay, 2
2 N
ov
emb
er 20
08 14
Axel A
ngeli-
(c) 20
08
logo
swo
rld.co
m -
Bu
ildin
g the SO
A C
ity
SenderServer
Fire &Forget
Logosworld.com
SOA City
Building SOA City by Lynton Grice Logosworld SOA India 17.Nov 2008 Bangalore
Broadcast
• One sender, unknown number of receivers• Website
• Message Queue, Database
• Event Triggers
• Sender Does not know, who is listening
Saturd
ay, 2
2 N
ov
emb
er 20
08 15
Axel A
ngeli-
(c) 20
08
logo
swo
rld.co
m -
Bu
ildin
g the SO
A C
ity
Sender
Publish
Logosworld.com
SOA City
Building SOA City by Lynton Grice Logosworld SOA India 17.Nov 2008 Bangalore
Communication Patterns
Saturd
ay, 2
2 N
ov
emb
er 20
08 16
Axel A
ngeli -
(c) 20
08
logo
swo
rld.co
m -
Bu
ildin
g the SO
A C
ity
Logosworld.com
SOA City
Building SOA City by Lynton Grice Logosworld SOA India 17.Nov 2008 Bangalore
Filter Pattern
Receive
Transform
Send
Sender
Ad
ap
ter
Ad
ap
ter
FilterReceiver
Logosworld.com
SOA City
Building SOA City by Lynton Grice Logosworld SOA India 17.Nov 2008 Bangalore
Basic Communication Pattern
All follow the same communication flow Sender
• Format Conversion
Internal Format• Format conversion
Receiver
Sender AdapterInternal Format
Adapter Receiver
SpeechSound
EARBrain
ElectricMOUTH
SpeechSound
Logosworld.com
SOA City
Building SOA City by Lynton Grice Logosworld SOA India 17.Nov 2008 Bangalore
Because we always revert to some pre-thought algorithm
Patterns reduce complexity
Saturd
ay, 2
2 N
ov
emb
er 20
08 19
Axel A
ngeli -
(c) 20
08
logo
swo
rld.co
m -
Bu
ildin
g the SO
A C
ity
Logosworld.com
SOA City
Building SOA City by Lynton Grice Logosworld SOA India 17.Nov 2008 Bangalore
Especially the reuse of tools andmonitoring components
Patterns allow reuse
Saturd
ay, 2
2 N
ov
emb
er 20
08 20
Axel A
ngeli -
(c) 20
08
logo
swo
rld.co
m -
Bu
ildin
g the SO
A C
ity
Logosworld.com
SOA City
Building SOA City by Lynton Grice Logosworld SOA India 17.Nov 2008 Bangalore
Patterns Ancestry
Pass Filter (A-1-B)
Null Filter (A-0-B) Proxy (A-1-B) Request/Reply (A-1-A) Throttling (A-time-B)
Fan Out (1:n)
Fan out (1:n) Fan out & collect (1:n:1) Load balance (1-1/n)
Message queue
Queue-in/out
Queue and Forward
Campaign
Queue and reply
Logosworld.com
SOA City
Building SOA City by Lynton Grice Logosworld SOA India 17.Nov 2008 Bangalore
Logosworld.com
Layers
22
.11
.20
08
22
Logosworld.com
SOA City
Building SOA City by Lynton Grice Logosworld SOA India 17.Nov 2008 Bangalore
Data Layer versus Transport layer
In Process Out
Saturd
ay, 2
2 N
ov
emb
er 20
08 23
Axel A
ngeli-
(c) 20
08
logo
swo
rld.co
m -
Bu
ildin
g the SO
A C
ity
HTTP XML SOAP
Data layer
Transport Layer
Logosworld.com
SOA City
Building SOA City by Lynton Grice Logosworld SOA India 17.Nov 2008 Bangalore
Content strictly separate from Envelope
Content
EDIFACT
IDOC
Envelope
SOAP
XML
HTML
JSON
24
Logosworld.com
SOA City
Building SOA City by Lynton Grice Logosworld SOA India 17.Nov 2008 Bangalore
22
.11
.20
08
25
Logosworld.com
SOA City
Building SOA City by Lynton Grice Logosworld SOA India 17.Nov 2008 Bangalore
Interaction Transport/Data-Layer
Saturd
ay, 2
2 N
ov
emb
er 20
08 26
Axel A
ngeli -
(c) 20
08
logo
swo
rld.co
m -
Bu
ildin
g the SO
A C
ity
Logosworld.com
SOA City
Building SOA City by Lynton Grice Logosworld SOA India 17.Nov 2008 Bangalore
Logosworld.com
Atomic Patterns
Saturd
ay, 2
2 N
ov
emb
er 20
08 27
Axel A
ngeli -
(c) 20
08
logo
swo
rld.co
m -
Bu
ildin
g the SO
A C
ity
Logosworld.com
SOA City
Building SOA City by Lynton Grice Logosworld SOA India 17.Nov 2008 Bangalore
Atom: Pass Filter
Message is handled and filtered by an algorithm during pass through
Sender
Ad
ap
ter
Ad
ap
ter
FilterReceiver
Logosworld.com
SOA City
Building SOA City by Lynton Grice Logosworld SOA India 17.Nov 2008 Bangalore
Pass Filter Variation: Transformation
Message payload is changed by the filter
Sender
Ad
ap
ter
Ad
ap
ter
ProcessReceiver
Logosworld.com
SOA City
Building SOA City by Lynton Grice Logosworld SOA India 17.Nov 2008 Bangalore
Pass Filter Variation: Mapping
Message payload is changed by the filter
Sender
Ad
ap
ter
Ad
ap
ter
ProcessReceiver
Fox
Wolf
Hound
Hyane
Tiger
Dogs
Cats
Logosworld.com
SOA City
Building SOA City by Lynton Grice Logosworld SOA India 17.Nov 2008 Bangalore
Pa
tie
nt
Fil
e
Pass Filter: Content based routing
Receiver depends on message content
Sender
Ad
apte
r
Ad
apte
r
ProcessReceiver
Age=45
Female
Age=12
Male
Pregnant
Gynecologist
Psychatrist
Pediatric
12yr old girl
35yr old lady
A man
Logosworld.com
SOA City
Building SOA City by Lynton Grice Logosworld SOA India 17.Nov 2008 Bangalore
Null Filter
A special case of a pass filter that would not change the message‘s payload Usages: Protocol converter
Bridge between media
Decouple sender and receiver to avoid impact
Ad
ap
ter
Ad
ap
ter
Null-Filter
Logosworld.com
SOA City
Building SOA City by Lynton Grice Logosworld SOA India 17.Nov 2008 Bangalore
Atom: Proxy - Asynchronous Capsule
Services are activated asynchronously only Proxy provides emulation of synchronous processing
Ad
ap
ter
Ad
ap
ter
Requester Collector
Service
Logosworld.com
SOA City
Building SOA City by Lynton Grice Logosworld SOA India 17.Nov 2008 Bangalore
Atom: Request Reply Pattern
Request-reply patterns are filter where sender and receiver are the same entity
Ad
ap
ter
Service
Logosworld.com
SOA City
Building SOA City by Lynton Grice Logosworld SOA India 17.Nov 2008 Bangalore
Atom: Fanout
A fan-out distributes a message to list of registered subscribers
Ad
apte
r
Ad
apte
r
ProcessSubscription
Handler
Ad
apte
rA
dap
ter
Sender ProcessDetermineSubscriber
Fan-OutReceivers
Receiver
Logosworld.com
SOA City
Building SOA City by Lynton Grice Logosworld SOA India 17.Nov 2008 Bangalore
Atom: Fanout and Collect
This pattern fans out the messages and then waits for all tasks to terminate
Ad
apte
rDistributor
Ad
apte
rA
dap
ter
Synchronizer
Ad
apte
rA
dap
ter
Ad
apte
r
SenderDistri-bute
Fan-Out Re-Sync Receiver
Logosworld.com
SOA City
Building SOA City by Lynton Grice Logosworld SOA India 17.Nov 2008 Bangalore
Dispatcher
Atom: Load Balancing
Receive a message and assign to the next available ressource to process from
Ad
apte
r
Ad
apte
rA
dap
ter
Ad
apte
r
Process
Process
Process
Ad
apte
r
SenderMQ-
InboxProcess Receiver
Logosworld.com
SOA City
Building SOA City by Lynton Grice Logosworld SOA India 17.Nov 2008 Bangalore
Atom: Load Throttling
Messages are stored in an MQ and then dispatched to processes that signal availability
Ad
apte
r
QueueJanitor
Ad
apte
rA
dap
ter
MQ
Process
Process
Process
Ad
apte
r
SenderMQ-
InboxProcess Receiver
Logosworld.com
SOA City
Building SOA City by Lynton Grice Logosworld SOA India 17.Nov 2008 Bangalore
Passive Dispatching
Receiver peeks messages
Active Dispatching
Messages are forwarded
Active and Passive Throttling
Messages are normally fetched by a free handler If processor is unable to poll, MQ may forward messages
QueueJanitor
MQ
Process
Process
Process
QueueJanitor
MQ
Process
Process
Process
Logosworld.com
SOA City
Building SOA City by Lynton Grice Logosworld SOA India 17.Nov 2008 Bangalore
Atom: Galvanic Decoupling (Q&Forward)
The process will deploy the response into a message queue for next process to pick up
MQ Process
Process
MQ
SenderMQ-
InboxProcess
MQ-Outbox
NextProcess
Logosworld.com
SOA City
Building SOA City by Lynton Grice Logosworld SOA India 17.Nov 2008 Bangalore
Atom: Campaigning
Message will be made public in a queue A watchdog will remove the queue after expiration
QueueJanitor
MQ
Process Process
WatchDog
Sender MQ-Inbox Published Withdraw
Process
Logosworld.com
SOA City
Building SOA City by Lynton Grice Logosworld SOA India 17.Nov 2008 Bangalore
Atom: Sorting & Merging Queues
Messages need to be sorted
Queues need to be merged I to one queue
QueueMerger
MQ
Process
Ad
apte
r
SenderMQ-
InboxesMerger Process Receiver
MQ
MQ
Logosworld.com
SOA City
Building SOA City by Lynton Grice Logosworld SOA India 17.Nov 2008 Bangalore
Merged Queues
Saturd
ay, 2
2 N
ov
emb
er 20
08 43
Axel A
ngeli -
(c) 20
08
logo
swo
rld.co
m -
Bu
ildin
g the SO
A C
ity
Logosworld.com
SOA City
Building SOA City by Lynton Grice Logosworld SOA India 17.Nov 2008 Bangalore
Merge Difficulties
Allow hysteresis of merge keys
• E.g. time stamps differ by up to 1 second
Wait before starting merge
Some queue may take longer to fill up
• E.g. snapshots taken every x seconds only
Calculate Default drop out values
• E.g. RFID tag is not read
Saturd
ay, 2
2 N
ov
emb
er 20
08 44
Axel A
ngeli -
(c) 20
08
logo
swo
rld.co
m -
Bu
ildin
g the SO
A C
ity
Logosworld.com
SOA City
Building SOA City by Lynton Grice Logosworld SOA India 17.Nov 2008 Bangalore
Atom: Bucketing
• Process is halted until a number of messages arrive
• Lock prevention needs to be configurable• E.g Timeout, trigger message („joker“)
Process
SenderMQ-
InboxesWait for
fillProcess Receiver