MTAT 03 229MTAT.03.229 Enterprise System Integration ... · the business process Immediately...

30
MTAT 03 229 MTAT.03.229 Enterprise System Integration Lecture 10: Implementing Process-Centric Composite Services in BPEL Marlon Dumas marlon . dumas ät ut . ee

Transcript of MTAT 03 229MTAT.03.229 Enterprise System Integration ... · the business process Immediately...

Page 1: MTAT 03 229MTAT.03.229 Enterprise System Integration ... · the business process Immediately terminate execution of a business i reply exit Invoke a one-way or request-response operation

MTAT 03 229MTAT.03.229Enterprise System Integration

Lecture 10: Implementing Process-Centric Composite Services in BPEL

Marlon Dumas

marlon . dumas ät ut . ee

Page 2: MTAT 03 229MTAT.03.229 Enterprise System Integration ... · the business process Immediately terminate execution of a business i reply exit Invoke a one-way or request-response operation

Questions about reading materialQuestions about reading material

• Week 8: Zimmermann, Doubrovski, Grundler & Hogg: Service-orientedWeek 8: Zimmermann, Doubrovski, Grundler & Hogg: Service orientedarchitecture and business process choreography in an order management scenario: rationale, concepts, lessons learned.

Which business processes needed to be automated in this project?– Which business processes needed to be automated in this project?– What types of activities appeared in these business processes?– What types of customers needed to interact with these processes?at types o custo e s eeded to te act t t ese p ocesses– What were the perceived benefits of using an SOA?– What technology was used to implement these processes and why?

• Week 9: Szabelak & Topinski: The Tao of Service-Oriented Architecture Governance.– What are the phases in the proposed SOA roadmap?What are the phases in the proposed SOA roadmap?– What are the key elements of the proposed approach to facilitate

minimize SOA project interdependencies?

2

Page 3: MTAT 03 229MTAT.03.229 Enterprise System Integration ... · the business process Immediately terminate execution of a business i reply exit Invoke a one-way or request-response operation

SOA Lifecycle and RolesSOA Lifecycle and Roles

DeveloperWeek 7& 8

Service & Process

Implementation

Service & Process

Design

p

SolutionArchitect

Weeks 10 & 11

pg

Tester

Service & ProcessAnalysis

Testing &Deployment

Week 6

Analysis

BusinessA l t

Operation &Monitoring

Opportunity & Issue

Identification

AnalystAdministrator

3

Page 4: MTAT 03 229MTAT.03.229 Enterprise System Integration ... · the business process Immediately terminate execution of a business i reply exit Invoke a one-way or request-response operation

Breaking Silos With Process-Centric Composite Services

Business Logic

Manufacture Sales Logistics Finance

Business Logic

Business Logic

Business Logic

Manufacture Sales Logistics Finance

System Silos Integrated Systems

4 4 / 112

Page 5: MTAT 03 229MTAT.03.229 Enterprise System Integration ... · the business process Immediately terminate execution of a business i reply exit Invoke a one-way or request-response operation

Web Service Technology StackWeb Service Technology StackOrchestration

Description

BPEL

AdvertisementDescription

WSDL, XML Schema, WS-Policy

Advertisement

UDDI

Messaging

WS Addressing

SOAP

WS-Addressing, WS-ReliableMessaging, WS-Security...

Transport Format

5HTTP, SMTP, FTP XML

Page 6: MTAT 03 229MTAT.03.229 Enterprise System Integration ... · the business process Immediately terminate execution of a business i reply exit Invoke a one-way or request-response operation

BPELBPEL• Business Process Execution Language (also

called WS-BPEL, BPEL4WS)• Language specifically designed to implement g g p y g p

process-centric services• Version 1 0 & 1 1 proposed by major vendors;Version 1.0 & 1.1 proposed by major vendors;

version 2.0 is an OASIS standard• XML Syntax but vendors provide visual• XML Syntax, but vendors provide visual

notations, e.g. Oracle BPEL, IBM WebSphere (demo at the end of lecture)(demo at the end of lecture)

6

Page 7: MTAT 03 229MTAT.03.229 Enterprise System Integration ... · the business process Immediately terminate execution of a business i reply exit Invoke a one-way or request-response operation

Why BPEL?Why BPEL?• One could implement process-centric services in

Java or C#Java or C#• But instead of hard-coding rules regarding

important business processes in applicationimportant business processes in application code – we take this information out of the application code and put it under the control of a BPM t ( b d BPEL)BPM system (e.g. based on BPEL).

• Facilitates Business Process:Modification– Modification

– Reconfiguration– OptimizationOptimization

• Graphical tools can be used to visualize process flow.

7

Page 8: MTAT 03 229MTAT.03.229 Enterprise System Integration ... · the business process Immediately terminate execution of a business i reply exit Invoke a one-way or request-response operation

BPEL OverviewBPEL Overview

...

P

employeeDB

..

Process-Centric Service

(BPEL)

HR

..bank

...

courier

8

courier© R. Khalaf et al.

Page 9: MTAT 03 229MTAT.03.229 Enterprise System Integration ... · the business process Immediately terminate execution of a business i reply exit Invoke a one-way or request-response operation

BPEL Overview (cont )BPEL Overview (cont.)

......

9© R. Khalaf et al.

Page 10: MTAT 03 229MTAT.03.229 Enterprise System Integration ... · the business process Immediately terminate execution of a business i reply exit Invoke a one-way or request-response operation

BPEL FeaturesBPEL Features• At its core, BPEL is an imperative programming

language: – scoped variables– assignment– sequence – while– if … then … else – exception handlers (throw / catch)

10

Page 11: MTAT 03 229MTAT.03.229 Enterprise System Integration ... · the business process Immediately terminate execution of a business i reply exit Invoke a one-way or request-response operation

BPEL Features (cont )BPEL Features (cont.)BPEL offers few features specific to pWS programming:

XML variable typing (XML Schema or WSDL)– XML variable typing (XML Schema or WSDL)– expressions can be written in XPath/XSL;

Message send and recei e actions– Message send and receive actions;– parallelism and synchronisation;

R diti ( ti ith– Race conditions (e.g. a message competing with a timer)transaction compensation;– transaction compensation;

– multiple sequential or concurrent executions of a block (foreach)

11

(foreach)

Page 12: MTAT 03 229MTAT.03.229 Enterprise System Integration ... · the business process Immediately terminate execution of a business i reply exit Invoke a one-way or request-response operation

BPEL Basic Activities

Do a blocking wait for a Generate a fault from inside receive throwmatching message to arrive

Send a message in reply to a formerly received message

the business process

Immediately terminate execution of a business

i

receive

reply

throw

exit

Invoke a one-way or request-response operation

U d t th l f

process instance

Wait for a given time period or until a certain time has passed

invoke wait

Update the values of variables or partner links with new data

Invoke compensation on an inner scope that has already completed

compensateassign

12© D. Koenig

Page 13: MTAT 03 229MTAT.03.229 Enterprise System Integration ... · the business process Immediately terminate execution of a business i reply exit Invoke a one-way or request-response operation

BPEL Structured ActivitiesBPEL Structured ActivitiesContained activities are executed in

Block and wait for a suitable i ( i )pickflow are executed in

parallel, partially ordered through control links

message to arrive (or time out)

Contained activity is performed multiple times

ti ll tl

pickflow

Contained activities are performed sequentially in lexical order

sequentially or concurrently

Select exactly one branch of activity from a set of choices ( l ll d “ it h” i BPEL

sequence forEach

order

Contained activity is repeated while a predicate holds

(also called “switch” in BPEL 1.1)

Associate contained activity ith it l l i bl

if then elsewhile

predicate holds

Contained activity is repeated until a predicate holds

with its own local variables, fault handlers, compensation handler, and event handlers

scoperepeatUntil

predicate holds

13© D. Koenig

Page 14: MTAT 03 229MTAT.03.229 Enterprise System Integration ... · the business process Immediately terminate execution of a business i reply exit Invoke a one-way or request-response operation

Nesting of ActivitiesNesting of Activities<sequence>

i /

sequence

<receive .../><flow>

<sequence><invoke .../>

receive

flow

<while ... ><assign>...</assign>

</while></sequence> receiveinvoke

sequencesequence

<sequence><receive .../><invoke ... >

</sequence>invokewhile

q</flow><reply>

</sequence>

assign

reply

14© D. Koenig

Page 15: MTAT 03 229MTAT.03.229 Enterprise System Integration ... · the business process Immediately terminate execution of a business i reply exit Invoke a one-way or request-response operation

BPEL Code Snippet 1BPEL Code Snippet 1

<process ><process …>…<sequence>

<receive partner=”HR” portType=”tns:processPT” operation=”op1” variable= ...receive partner HR portType tns:processPT operation op1 variable ... createInstance=”yes” />

<invoke partner=”employeeDB” portType= … operation =”op2" inputVariable=… outputVariable=.../> p p

<invoke partner=”bank” portType=… operation=”op3" inputVariable=… outputVariable=…/>

<invoke partner=”courier” portType=… operation=”op4" inputVariable=… outputVariable=…/>

<receive partner=”courier” portType=”tns:processPT” operation=”op5" variable=… /> <reply partner=”HR” portType=”tns:processPT” operation=”op1” variable =…/></sequence></sequence></process>

15

Page 16: MTAT 03 229MTAT.03.229 Enterprise System Integration ... · the business process Immediately terminate execution of a business i reply exit Invoke a one-way or request-response operation

BPEL Code Snippet 2BPEL Code Snippet 2<flow>

<sequence><sequence><invoke name="inv1" partnerLink="pl1"

portType="pt1" operation="op1“ inputVariable="var1"/><receive name="rcv1" partnerLink="pl2"

portType="pt2" operation="op2“ variable="var2"/></sequence>/sequence<sequence><receive name="rcv2" partnerLink="pl1“

tT " t2" ti " 2“ i bl " 3"/portType="pt2" operation="op2“ variable="var3"/><receive name="rcv3" partnerLink="pl3“

portType="pt3" operation="op2“ variable="var4"/>p yp p p p</sequence>

</flow>

16

Page 17: MTAT 03 229MTAT.03.229 Enterprise System Integration ... · the business process Immediately terminate execution of a business i reply exit Invoke a one-way or request-response operation

Scopes and Handlers

• Scope– Local variables

scope

– Local partner links– Local correlation sets– Set of activities (basic or structured)

eventhandlers

partnerli k

variables

faulthandler

• Handlers– Event handlers

• Message events or timer events

faulthandlerscorrelation

sets

links

. . .

g(deadline or duration)

– Fault handlers• Dealing with different exceptional

situations (internal faults)compensation

handler

. . .– Compensation handler

• Undoing persisted effects of already completed activities

– Termination handlertermination

handler

. . .. . .

. . .

• Dealing with forced scope termination (external faults) . . .

17© D. Koenig

Page 18: MTAT 03 229MTAT.03.229 Enterprise System Integration ... · the business process Immediately terminate execution of a business i reply exit Invoke a one-way or request-response operation

Fault Handling and Compensation

Process

faulthandlersequence

compensation

notifymanager

fault

scopescope

handler

chargecredit card

refundcustomer

shipgoods

compensatehandler

rethrow

1818

© D. Koenig

Page 19: MTAT 03 229MTAT.03.229 Enterprise System Integration ... · the business process Immediately terminate execution of a business i reply exit Invoke a one-way or request-response operation

BPEL and WSDL

• Every BPEL process definition is exposed as a web service whose interface is defined in WSDLwhose interface is defined in WSDL

• BPEL only depends on the “abstract” part of a WSDL interface definition (not on the “binding”)( g )

• WSDL / XML Schema are used to describe variable types in a BPEL process definition

Loan Approval Process

WSDLLoan ApprovalPortType

receive

reply

19

WebService

Page 20: MTAT 03 229MTAT.03.229 Enterprise System Integration ... · the business process Immediately terminate execution of a business i reply exit Invoke a one-way or request-response operation

BPEL and WSDL (cont.)

• In addition to “providing” a service, a BPEL process definition consumes other servicesconsumes other services

• The interfaces of “consumed” services are defined in WSDL

Interfaces exposedby the BPEL process

Interfaces consumedby the BPEL process

Loan Approval Process

WSDLLoan

Loan Approval ProcessApprovalPortType

Financial Institution‘sinvoke

receive

WebS i

WebS i

Web Service(Loan Approver)

reply

20

Service Service

Page 21: MTAT 03 229MTAT.03.229 Enterprise System Integration ... · the business process Immediately terminate execution of a business i reply exit Invoke a one-way or request-response operation

BPEL and WSDL (cont.)

• When using “asynchronous” interactions, a BPEL process may need to treat its “caller” as a service itselfprocess may need to treat its caller as a service itself –with its own WSDL…

Service PService A Service B

invoke

receive

receive

invoke

invoke

A’s WSDL P’s WSDL B’s WSDL

21Partner Link Type Partner Link Type

Page 22: MTAT 03 229MTAT.03.229 Enterprise System Integration ... · the business process Immediately terminate execution of a business i reply exit Invoke a one-way or request-response operation

BPEL and WSDL (cont )BPEL and WSDL (cont.)

22

Page 23: MTAT 03 229MTAT.03.229 Enterprise System Integration ... · the business process Immediately terminate execution of a business i reply exit Invoke a one-way or request-response operation

BPEL and WSDL (cont )BPEL and WSDL (cont.)

WSDLXSD

WSDLXSD

WSDLXSD

WSDLXSD

WSDLXSD

WSDLXSD

23

Page 24: MTAT 03 229MTAT.03.229 Enterprise System Integration ... · the business process Immediately terminate execution of a business i reply exit Invoke a one-way or request-response operation

BPEL Partner Link DefinitionBPEL Partner Link DefinitionWSDL code snippet:<portType name=“salesPT">

<operation name=“order">…

<portType name=“customerPT"><operation name=“orderResponse"><operation name= orderResponse >

<partnerLinkType name="salesPLT"><role name=“sales">

<portType name=“salesPT"/></role><role name=“customer"><role name= customer >

<portType name=“customerPT"/></role>

</partnerLinkType>

BPEL code snippet:<partnerLinks>

<partnerLink name="salesPL“ myRole=“sales“

24

<partnerLink name= salesPL myRole= sales partnerRole=“customer" partnerLinkType="salesPLT"/> …

Page 25: MTAT 03 229MTAT.03.229 Enterprise System Integration ... · the business process Immediately terminate execution of a business i reply exit Invoke a one-way or request-response operation

Correlation in BPELCorrelation in BPEL

• “Synchronous” interactions are not always and option in process-centric processes because:

Wh i t f t i i i– When an instance of a process-centric service is created, its execution may last for days, weeks or even months…even months…

– Process-centric service definitions need not follow request/response interaction patterns

• Need to use asynchronous interactions• This in turns require “correlation”q

25

Page 26: MTAT 03 229MTAT.03.229 Enterprise System Integration ... · the business process Immediately terminate execution of a business i reply exit Invoke a one-way or request-response operation

Correlation in BPEL (cont )Correlation in BPEL (cont.)

Two correlation methods are supported:• The “easy” way: Use WS-Adressing headers in

all SOAP messages– Every message has a “messageID”

f– A message may refer to a previous message through a “relatesTo” headerRequires that all services use SOAP and WS– Requires that all services use SOAP and WS-Addressing…

– Not applicable in some advanced scenariospp• The “hard” way: Correlation sets…

26

Page 27: MTAT 03 229MTAT.03.229 Enterprise System Integration ... · the business process Immediately terminate execution of a business i reply exit Invoke a one-way or request-response operation

BPEL Correlation SetsBPEL Correlation Sets

27© R. Khalaf

Page 28: MTAT 03 229MTAT.03.229 Enterprise System Integration ... · the business process Immediately terminate execution of a business i reply exit Invoke a one-way or request-response operation

BPEL Correlation Sets (snippets)BPEL Correlation Sets (snippets)WSDL snippet: <bpws:property name="employeeID" type="xsd:long"/>

b t Ali t N "t l ID" T "t HRP i R tM " <bpws:propertyAlias propertyName="tns:emplyeeID" messageType="tns:HRPensionRqstMsg" part="employeeRecord" query="/employeeRecord/employeeID"/>

BPEL snippet:<process …><partnerLinks> … </partnerLinks><variables> … </variables> <correlationSets> <correlationSet name="employeeNum" properties="tns:employeeID"/> </correlationSets><sequence> <receive partner=”HR” portType=”tns:processPT” operation=”processPension” variable=”request” createInstance=”yes”> <correlationSets> <correlations set=”employeeNum” initiate=”yes”/></correlationSets> </receive> ….. <receive partner=”HR” portType=”tns:processPT” operation=”complete” variable =”completionInfo”> <correlationSets> <correlations set=”employeeNum” /></correlationSets> </receive> </sequence>

28

q</process>

Page 29: MTAT 03 229MTAT.03.229 Enterprise System Integration ... · the business process Immediately terminate execution of a business i reply exit Invoke a one-way or request-response operation

Human Tasks

Human Task

Executable Business Process (BPEL)

A2

Management Service

A1

A3

A2

A4

Service A1 Service A2 Service A3 Service A4

Service Bus / Container

App1: COBOL App2: PL1 App3: Java App4: C#

29

Page 30: MTAT 03 229MTAT.03.229 Enterprise System Integration ... · the business process Immediately terminate execution of a business i reply exit Invoke a one-way or request-response operation

References and AcknowledgmentReferences and Acknowledgment• This lecture material is based on:

– C. Ouyang, W.M.P. van der Aalst, M. Dumas, A.H.M. terHofstede and M. La Rosa. Service-Oriented Processes: An Introduction to BPEL . In "Semantic Web Services: Theory,Introduction to BPEL . In Semantic Web Services: Theory, Tools and Applications". Idea Group, March 2007.

– R. Khalaf et al.: “The Business Process Execution Language for Web Services” Chapter 13 of “Process Aware InformationWeb Services . Chapter 13 of Process-Aware Information Systems”, John Wiley & Sons, 2005

– Some slides are taken from a presentation “Introduction to BPEL” by Dieter König, IBM

• “Reading” of the week :– Week 10 (video presentation). D. Syer: Introducing

Spring Batch Processing. QCon London 2008

30