MTAT.03.229 Enterprise System Integration
Lecture 10. Process-Centric Services: Design & Implementation
Marlon Dumas
marlon . dumas ät ut . ee
2
SOA Lifecycle
Service & Process
Implementation
Service & Process Analysis
Service & Process Design
Testing & Deployment
Operation & Monitoring
Opportunity & Issue
Identification
Business Analyst
Developer
Tester
Administrator
Solution Architect
2 / 112
3
Recall – Order Management Scenario
4
sales
warehouse
customer
finance
Recall – Order Management Scenario
5
Supplier
Let’s have a look inside…
6
Process-Centric Service Design: Concepts
• Interaction: information exchange between two services; involves one or more communication tasks on each side.
• Communication action – Send message – Receive message
• Internal action – Data transformation/manipulation, – Invocation to an unit of processing (e.g. provided by a
component
7
Viewpoints in Process-Centric Service Design
• Choreography – Global model of the interactions between two or more services. – No preferred party – Only interactions, no internal actions
• Interface (Behavioural and Structural) – Model of the interactions between a service and one or several
other services; – Only interactions, no internal actions
• Orchestration – Model of the interactions and internal actions that a (composite)
service needs to undertake to achieve a goal.
8
Choreography
9
Behavioural Interface (Order Management)
10
Orchestration (Order Management)
11
Process-Centric Service Design Methods
• Choreography-driven Service Design – Design a choreography in collaboration with my partners; – Determine which interactions in the choreography involve me; – Derive the behavioural interfaces I need to implement; – Implement the behavioural interfaces.
• Orchestration-driven Service Design – Define an orchestration and find appropriate services to plug into
it (these two steps can be done in either order); – Derive a behavioural interface from the orchestration; – Expose this interface to the outside world.
• In some cases, mismatches can occur…
12
Provided vs. Required Interfaces
Buyer B Buyer A
Order Response
RCV
Purchase Order
SND
End
Purchase Order
SND
Order Response
RCV
End
No
Yes All Responses
Received?
Seller
Buyer B's provided ("as is") interface
Purchase Order Choreography Buyer B's
required ("to be") interface
13
Choreography & Orchestration: Summary
provided interface
. . .
orchestration
choreography
Internal service/API
required interface
Adaptation
Adaptation Adaptation
14
BPEL
• Business Process Execution Language (BPEL) • Domain-Specific Language for implementing
process-centric services (orchestrations) • XML Syntax, but vendors provide visual
notations, e.g. – Oracle SOA Suite – ActiveVOS – IBM WebSphere (dialect) – Windows Workflow Foundation (dialect)
• Alternative: BPMN 2.0
15
Why BPEL?
• One could implement process-centric services in Java or C#
16
Why BPEL (cont.)
• But instead of hard-coding important business processes in application code – we put it under the control of a BPM system
• Facilitates: – Modification – Reconfiguration – Optimization
• Graphical tools can be used to visualize process flow
17
BPEL Overview
• At its core, BPEL is an imperative programming language: – scoped variables – assignment – sequence – while – if … then … else – exception handlers (throw / catch)
18
BPEL overview (cont.) BPEL offers few features specific to WS programming: – XML variable typing (XML Schema or WSDL) – expressions can be written in XPath/XSL – Message send and receive actions – parallelism and synchronisation – Race conditions (e.g. message competing with a timer) – multiple sequential or concurrent executions of a block
(foreach)
– …
19
MyProcess
invoke
receive
receive
invoke
invoke
Basic Activities
receive
reply
invoke
throw
exit
wait
empty
compensate validate
assign
rethrow
extensionActivity
compensateScope
Structured Activities if-else
while
scope
pick
sequence
flow
repeatUntil
forEach
Handlers
fault handler
event handler
fault handler
compensation handler
termination handler
event handler
Partner Links
Partner Link Type
Port Type 1
Port Type 2
partner link
partner link
Variables 42
WSDL Message
XML Schema Type
XML Schema Element
Properties Correlation Sets
Property 1
Property 2
© F. Casati et al.
20
BPEL Data Model: Variables
20
0
1
Assignment activities move data around
Activities’ input and output kept in scoped variables
Scoped variables typed as WSDL messages or XML Schema elements/types
. . . invoke
assign
reply
. . .
receive
42
© F. Casati et al.
21
Partner Links
• Partner link: instance of typed connector – Partner link type specifies required and/or provided
portTypes (NOT the actual service) – Channel along which a peer-to-peer conversation with
a partner takes place
Partner Link Type
Port Type 1
Port Type 2
Process 1 Process 2
© F. Casati et al.
22
Partner Links
ProcesspurchaseOrderProcess
computePricePTPartnerLink
invoicinginvoiceCallbackPT
shippingPTPartnerLink
shippingshippingCallbackPT
schedulingPTPartnerLinkscheduling
purchaseOrder PTPartnerLinkpurchasing
ProcesspurchaseOrderProcess
computePricePTPartnerLink
invoicinginvoiceCallbackPT
shippingPTPartnerLink
shippingshippingCallbackPT
schedulingPTPartnerLinkscheduling
purchaseOrder PTPartnerLinkpurchasing
I declare what I need and what I offer
© F. Casati et al.
23
Basic Activities
Do a blocking wait for a matching message to arrive
Send a message in reply to a formerly received message
Invoke a one-way or request-response operation
updates values of variables or partner links
receive
reply
invoke
assign
© F. Casati et al.
24
Receive
<receive partnerLink="purchasing" portType="lns:purchaseOrderPT"
operation="sendPurchaseOrder" variable="PO"
createInstance="yes">
<documentation>Receive Purchase Order</documentation>
</receive>
© F. Casati et al.
25
Reply
Receive+Reply request/response
25
<reply partnerLink="purchasing" portType="lns:purchaseOrderPT" operation="sendPurchaseOrder" variable="Invoice"> <documentation>Invoice Processing</documentation> </reply>
© F. Casati et al.
26
Invoke
<invoke partnerLink="shipping" portType="lns:shippingPT" operation="requestShipping" inputVariable="shippingRequest" outputVariable="shippingInfo"> <documentation>Decide On Shipper
</documentation> … </invoke>
For one-way message sending, outputVariable is omitted
© F. Casati et al.
27
More Basic Activities…
exit
wait Wait for a given time period or until a certain time has passed
Immediately terminate execution of a business process instance
<wait> <until>'2009-12-24T18:00+01:00'</until> </wait>
<wait> <for>’P1Y10M28DT10H37M46S’</for> </wait>
© F. Casati et al.
28
BPEL Structured Activities
Contained activities are executed in parallel, partially ordered through control links
Contained activities are performed sequentially in lexical order
Contained activity is repeated while a predicate holds
Contained activity is repeated until a predicate holds
Block and wait for a suitable message to arrive (or time out)
Contained activity is performed multiple times sequentially or concurrently
Select exactly one branch of activity from a set of choices (also called “switch” in BPEL 1.1)
Associate contained activity with its own local variables, fault handlers, compensation handler, and event handlers
if then else while
scope
pick
sequence
flow
repeatUntil
forEach
© D. Koenig
29
Nesting of Activities
<sequence> <receive .../> <flow> <sequence> <invoke .../> <while ... > <assign>...</assign> </while> </sequence> <sequence> <receive .../> <invoke ... > </sequence> </flow> <reply> </sequence>
receive
reply
receive
invoke
invoke
assign
sequence
sequence sequence
flow
while
© D. Koenig
30
Sequence
sequence
<sequence> <wait> <until>'2009-12-24T18:00+01:00'</until> </wait> <invoke partnerLink="CallServer" portType="AutomaticPhoneCall" operation="TextToSpeech" inputVariable="seasonGreetings" /> </sequence>
© F. Casati et al.
31
If then else if then else
<if xmlns:inventory="http://supply-chain.org/inventory" xmlns:FLT="http://example.com/faults"> <condition> bpel:getVariableProperty('stockResult','inventory:level') > 100 </condition> <flow> <!-- perform fulfillment work --> </flow> <elseif> … </elseif> <else> <throw faultName="FLT:ItemDiscontinued" /> </else> </if>
32
Loops
while repeatUntil
<while> <condition>$orderDetails > 100</condition> <scope>...</scope> </while>
forEach
<forEach counterName="po”> <startCounterValue>1</startCounterValue> <finalCounterValue> count($purchaseOrder/itemsList/*) </finalCounterValue> <scope>… </scope> </forEach>
33
. . .
fault handler
Scopes and Handlers
• Scope – Local variables – Local partner links – Local correlation sets – Set of activities (basic or structured)
• Handlers – Event handlers
• Message events or timer events (deadline or duration)
– Fault handlers • Dealing with different exceptional
situations (internal faults) – Compensation handler
• Undoing persisted effects of already completed activities
– Termination handler • Dealing with forced scope termination
(external faults)
fault handlers
compensation handler
termination handler
event handlers
. . .
. . .
. . .
. . .
correlation sets
partner links
scope
variables
© D. Koenig
34
Human Tasks
App1: COBOL App2: PL1 App3: Java App4: C#
Service Bus / Container
Service A1 Service A2 Service A3 Service A4
Executable Business Process (BPEL)
A1
A3
A2 A4
Human Task Handling Service
35
References and Acknowledgments
• This lecture material is based on: – R. Khalaf et al.: “The Business Process Execution Language for
Web Services”. Chapter 13 of “Process-Aware Information Systems”, John Wiley & Sons, 2005
– Some slides taken from lecture material by Fabio Casati, with permission
Top Related