MTAT.03.229 Enterprise System Integration Lecture 10 ... · BPEL • Business Process Execution...

35
MTAT.03.229 Enterprise System Integration Lecture 10. Process-Centric Services: Design & Implementation Marlon Dumas marlon . dumas ät ut . ee

Transcript of MTAT.03.229 Enterprise System Integration Lecture 10 ... · BPEL • Business Process Execution...

Page 1: MTAT.03.229 Enterprise System Integration Lecture 10 ... · BPEL • Business Process Execution Language (BPEL) • Domain-Specific Language for implementing process-centric services

MTAT.03.229 Enterprise System Integration

Lecture 10. Process-Centric Services: Design & Implementation

Marlon Dumas

marlon . dumas ät ut . ee

Page 2: MTAT.03.229 Enterprise System Integration Lecture 10 ... · BPEL • Business Process Execution Language (BPEL) • Domain-Specific Language for implementing process-centric services

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

Page 3: MTAT.03.229 Enterprise System Integration Lecture 10 ... · BPEL • Business Process Execution Language (BPEL) • Domain-Specific Language for implementing process-centric services

3

Recall – Order Management Scenario

Page 4: MTAT.03.229 Enterprise System Integration Lecture 10 ... · BPEL • Business Process Execution Language (BPEL) • Domain-Specific Language for implementing process-centric services

4

sales

warehouse

customer

finance

Recall – Order Management Scenario

Page 5: MTAT.03.229 Enterprise System Integration Lecture 10 ... · BPEL • Business Process Execution Language (BPEL) • Domain-Specific Language for implementing process-centric services

5

Supplier

Let’s have a look inside…

Page 6: MTAT.03.229 Enterprise System Integration Lecture 10 ... · BPEL • Business Process Execution Language (BPEL) • Domain-Specific Language for implementing process-centric services

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

Page 7: MTAT.03.229 Enterprise System Integration Lecture 10 ... · BPEL • Business Process Execution Language (BPEL) • Domain-Specific Language for implementing process-centric services

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.

Page 8: MTAT.03.229 Enterprise System Integration Lecture 10 ... · BPEL • Business Process Execution Language (BPEL) • Domain-Specific Language for implementing process-centric services

8

Choreography

Page 9: MTAT.03.229 Enterprise System Integration Lecture 10 ... · BPEL • Business Process Execution Language (BPEL) • Domain-Specific Language for implementing process-centric services

9

Behavioural Interface (Order Management)

Page 10: MTAT.03.229 Enterprise System Integration Lecture 10 ... · BPEL • Business Process Execution Language (BPEL) • Domain-Specific Language for implementing process-centric services

10

Orchestration (Order Management)

Page 11: MTAT.03.229 Enterprise System Integration Lecture 10 ... · BPEL • Business Process Execution Language (BPEL) • Domain-Specific Language for implementing process-centric services

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…

Page 12: MTAT.03.229 Enterprise System Integration Lecture 10 ... · BPEL • Business Process Execution Language (BPEL) • Domain-Specific Language for implementing process-centric services

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

Page 13: MTAT.03.229 Enterprise System Integration Lecture 10 ... · BPEL • Business Process Execution Language (BPEL) • Domain-Specific Language for implementing process-centric services

13

Choreography & Orchestration: Summary

provided interface

. . .

orchestration

choreography

Internal service/API

required interface

Adaptation

Adaptation Adaptation

Page 14: MTAT.03.229 Enterprise System Integration Lecture 10 ... · BPEL • Business Process Execution Language (BPEL) • Domain-Specific Language for implementing process-centric services

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

Page 15: MTAT.03.229 Enterprise System Integration Lecture 10 ... · BPEL • Business Process Execution Language (BPEL) • Domain-Specific Language for implementing process-centric services

15

Why BPEL?

•  One could implement process-centric services in Java or C#

Page 16: MTAT.03.229 Enterprise System Integration Lecture 10 ... · BPEL • Business Process Execution Language (BPEL) • Domain-Specific Language for implementing process-centric services

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

Page 17: MTAT.03.229 Enterprise System Integration Lecture 10 ... · BPEL • Business Process Execution Language (BPEL) • Domain-Specific Language for implementing process-centric services

17

BPEL Overview

•  At its core, BPEL is an imperative programming language: –  scoped variables –  assignment –  sequence –  while –  if … then … else –  exception handlers (throw / catch)

Page 18: MTAT.03.229 Enterprise System Integration Lecture 10 ... · BPEL • Business Process Execution Language (BPEL) • Domain-Specific Language for implementing process-centric services

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)

– …

Page 19: MTAT.03.229 Enterprise System Integration Lecture 10 ... · BPEL • Business Process Execution Language (BPEL) • Domain-Specific Language for implementing process-centric services

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.

Page 20: MTAT.03.229 Enterprise System Integration Lecture 10 ... · BPEL • Business Process Execution Language (BPEL) • Domain-Specific Language for implementing process-centric services

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.

Page 21: MTAT.03.229 Enterprise System Integration Lecture 10 ... · BPEL • Business Process Execution Language (BPEL) • Domain-Specific Language for implementing process-centric services

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.

Page 22: MTAT.03.229 Enterprise System Integration Lecture 10 ... · BPEL • Business Process Execution Language (BPEL) • Domain-Specific Language for implementing process-centric services

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.

Page 23: MTAT.03.229 Enterprise System Integration Lecture 10 ... · BPEL • Business Process Execution Language (BPEL) • Domain-Specific Language for implementing process-centric services

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.

Page 24: MTAT.03.229 Enterprise System Integration Lecture 10 ... · BPEL • Business Process Execution Language (BPEL) • Domain-Specific Language for implementing process-centric services

24

Receive

<receive partnerLink="purchasing" portType="lns:purchaseOrderPT"

operation="sendPurchaseOrder" variable="PO"

createInstance="yes">

<documentation>Receive Purchase Order</documentation>

</receive>

© F. Casati et al.

Page 25: MTAT.03.229 Enterprise System Integration Lecture 10 ... · BPEL • Business Process Execution Language (BPEL) • Domain-Specific Language for implementing process-centric services

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.

Page 26: MTAT.03.229 Enterprise System Integration Lecture 10 ... · BPEL • Business Process Execution Language (BPEL) • Domain-Specific Language for implementing process-centric services

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.

Page 27: MTAT.03.229 Enterprise System Integration Lecture 10 ... · BPEL • Business Process Execution Language (BPEL) • Domain-Specific Language for implementing process-centric services

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.

Page 28: MTAT.03.229 Enterprise System Integration Lecture 10 ... · BPEL • Business Process Execution Language (BPEL) • Domain-Specific Language for implementing process-centric services

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

Page 29: MTAT.03.229 Enterprise System Integration Lecture 10 ... · BPEL • Business Process Execution Language (BPEL) • Domain-Specific Language for implementing process-centric services

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

Page 30: MTAT.03.229 Enterprise System Integration Lecture 10 ... · BPEL • Business Process Execution Language (BPEL) • Domain-Specific Language for implementing process-centric services

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.

Page 31: MTAT.03.229 Enterprise System Integration Lecture 10 ... · BPEL • Business Process Execution Language (BPEL) • Domain-Specific Language for implementing process-centric services

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>

Page 32: MTAT.03.229 Enterprise System Integration Lecture 10 ... · BPEL • Business Process Execution Language (BPEL) • Domain-Specific Language for implementing process-centric services

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>

Page 33: MTAT.03.229 Enterprise System Integration Lecture 10 ... · BPEL • Business Process Execution Language (BPEL) • Domain-Specific Language for implementing process-centric services

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

Page 34: MTAT.03.229 Enterprise System Integration Lecture 10 ... · BPEL • Business Process Execution Language (BPEL) • Domain-Specific Language for implementing process-centric services

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

Page 35: MTAT.03.229 Enterprise System Integration Lecture 10 ... · BPEL • Business Process Execution Language (BPEL) • Domain-Specific Language for implementing process-centric services

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