business process management with rest - jopera · conference on business process management (bpm...
TRANSCRIPT
Business Process Management with REST
Cesare PautassoFaculty of Informatics
University of Lugano, Switzerland
[email protected]://www.pautasso.info
@pautasso
©2010 - Cesare Pautasso 2
BPM REST
©2010 - Cesare Pautasso 3
BusinessProcess
Management
RESTfulWeb Services
©2009-2010 - Cesare Pautasso - 30.6.2010 4
WS-* Standards Stack
©2009-2010 - Cesare Pautasso - 30.6.2010 5
WS-* Standards Stack
Interoperability
Metadata
Reliability
Security
Transactions
State
Messaging
ManagementBPM
©2010 - Cesare Pautasso 6
Interoperability
Metadata
Reliability
Security
Transactions
State
Messaging
ManagementBPM
Can you do it with REST?
©2010 - Cesare Pautasso 7
We believe there is huge potential to marrying REST with workflow and BPM.
[…]Combined with the architecture of the Web, a workflow service can provide both a truly simple, portable, and flexible way to build workflow driven integrations and applications.
From REST-* (JBoss)
http
://w
ww.
jbos
s.or
g/re
stst
ar/s
peci
ficat
ions
/wor
kflo
w.ht
ml“
”
©2010 - Cesare Pautasso 8
Workflow Management Engine
Act 1
Act 2
Act 3
Act 7
Act 6
Act 5
Act 4
WebServices
Process Model
Applications
Adapters
Workflow Users/Clients
Workflow Modelers
Workflow Participants
Business Process Management
Databases
BPMN/WS-BPEL
Bus
©2010 - Cesare Pautasso 9
WS-BPEL Primitives
WebService<invoke>
WebService
<invoke>
<receive><reply>
<receive>
The modeling language natively supports the RPC or message-based connectors
©2010 - Cesare Pautasso 10
What is your SOA connector today?
RPC ESB
REST/HTTP
©2010 - Cesare Pautasso 11
REST as a new connector
RPC ESB
REST/HTTP
Call
Publish/Subscribe
Get/Put/Post/Delete
©2010 - Cesare Pautasso 12
Is REST really used?
Atom, 2%
Gdata, 1%
JavaScript, 6%
JSON-RPC, 0%
REST, 71%
RSS, 1%
SMS, 0%
SOAP, 17%XML-RPC, 2%
XMPP, 0%
2042 APIs
ProgrammableWeb.com
30.6.2010
©2010 - Cesare Pautasso 13
Web Services expose their data and functionality trough resources identified by URI
Uniform Interface Principle: Clients interact with resources through a fix set of verbs. Example HTTP:GET (read), PUT (update), DELETE, POST (catch all),
Multiple representations for the same resource Hyperlinks model resource relationships and valid
state transitions for dynamic protocol description and discovery
REST in one slide
RPUT
DELETE
GET
POST
©2010 - Cesare Pautasso 14
RESTful Workflow Management Engine
Act 1
Act 2
Act 3
Act 7
Act 6
Act 5
Act 4
WebServices
Process Model
Applications
Adapters
Workflow Users/Clients
Workflow Participants
Business Process Management
Databases
BusRPUT
DELETE
GET
POST
©2010 - Cesare Pautasso 15
RESTful Workflow Management Engine
Act 1
Act 2
Act 3
Act 7
Act 6
Act 5
Act 4
Process Model
BPM with REST
R
R
RESTfulServiceCompositionRR
PublishingProcessesas Resources
©2010 - Cesare Pautasso 16
RESTful Workflow Management Engine
This talk will focus here
BPM with REST
R
R
RESTfulServiceCompositionRR
PublishingProcessesas Resources
©2010 - Cesare Pautasso 17
Some Challenges for BPM engines Can you drive the execution of tasks with
PUT/POST/DELETE requests? Can you monitor your processes with an
RSS/ATOM feed? Can you bookmark a process instance? Can you send an email to your colleague with a
link to a task from your worklist? Can you ask a process to give you links to its
tasks left to be done? Can you publish your process as a resource? Can you publish resources from your process? Can you call RESTful APIs directly?
©2010 - Cesare Pautasso 18
BPM REST Resources/URIs Uniform
Interface RepresentationsHypermedia
Processes Tasks Control FlowData Flow…
©2010 - Cesare Pautasso 19
Everything is a resource
Process ProcessInstance
Task TaskInstance
/process/X
/task/Y/task/Y/1
/process/X/1
©2010 - Cesare Pautasso 20
Hypermedia
Process ProcessInstance
Task TaskInstance
/process
/process/name
/process/name/instance
Follow links to discover the processesdeployed as resources
/process/name/instance/taskname
GET
GET
GET
©2010 - Cesare Pautasso 21
Representations
/process/nameGET
ContentType:
text/htmlContentType:
application/xml
ContentType:
text/plainContentType:
application/jsonContentType:
image/svg+xml
Web pagewith form to start
a new processinstance
Basic textualdescription
of the process
Process metadatain JSON
List of processinput parameters
©2010 - Cesare Pautasso 22
Uniform Interface and Hypermedia
/process
/process/name
GET
GET
GET
/process/namePOST
/process/name/instance
DELETE /process/name/instance
List the deployed processes
Get a form describing how
to start the process
Start a new process instance Check what
is the state of the
instance
Clean up(once it is done)
©2010 - Cesare Pautasso 23
Starting or Running a new process?
POST /process
Should the client be kept waiting for the process to run until completion?
Clients may want to block until the whole process has completed its execution(or it decides to reply to them)
/process
200 OK(Process Finished
Reply)
©2010 - Cesare Pautasso 24
Starting or Running a new process?
POST /process
GET /process/x
The client starting a long running process is redirected to a location x representing the newly started process instance
The process and the client run asynchronously
The client may retrieve the current state of the process instance at any time
/process
202 AcceptedLocation: x
200 OK
©2010 - Cesare Pautasso 25
Uniform Interface and Hypermedia
/task
/task/name/instance
GET
GET
GET
/task/name/instancePOST
/task/name/instance
List the active tasks Get a form
describing how to perform the
task
Finish the task
Get the finalrepresentation
of the completed task…
©2010 - Cesare Pautasso 26
POST or PUT?
/task
/task/name/instance
GET
GET
GET
/task/name/instancePOST
/task/name/instance
…
Note:PUT could also be
used hereto set the state
(Finished, Failed)of the task
27
Example: RESTBucks
Jim Webber, Savas Parastatidis, Ian Robinson http://restinpractice.com/
©2010 - Cesare Pautasso 28
Simple RESTBucks Example
/rest/restbucks/order/1.0/{id}
/tasks/restbucks/order/1.0/{id}/payment
/receipt/{uuid}
/rest/restbucks/order/1.0/ POST
POST
GET
GET
Resources
Private Tasks
©2010 - Cesare Pautasso 29
Simple RESTBucks ExampleHypermedia-centric service design (and implementation)done with a business process model
©2010 - Cesare Pautasso 30
Instantiating a processGET /rest/restbucks/order/1.0/
Retrieve a form which describes how to instantiate a new process
©2010 - Cesare Pautasso 31
Instantiating a processPOST /rest/restbucks/order/1.0/
Start = non blocking (redirect to URI of the new instance)
Run = blocking (client waits until the process replies)
©2010 - Cesare Pautasso 32
Interacting with a task
GET /task/restbucks/order/1.0/0/payment
©2010 - Cesare Pautasso 33
Interacting with a task
POST /rest/restbucks/order/1.0/0/payment
©2010 - Cesare Pautasso 34
Interacting with a resource
GET /receipt/2fc7f6e2-8b43-4672-a7c4…
©2010 - Cesare Pautasso 35
Interacting with a resource
DELETE /rest/restbucks/order/1.0/0
©2010 - Cesare Pautasso 36
Deleting a process resource
DELETE /rest/restbucks/order/1.0/0
©2010 - Cesare Pautasso 37
Viewpoints
DataFlow
ControlFlow
ServiceBindings
SQLREST.URI RESTREST.TASK WS-* …
©2010 - Cesare Pautasso 38
ControlFlow
Control FlowDependency
©2010 - Cesare Pautasso 39
ServiceBindings
SQL
REST.URI
REST
REST.TASK
WS-*
©2010 - Cesare Pautasso 40
REST.TASK
Specify the final state of the Payment task
©2010 - Cesare Pautasso 41
REST.URI
Specify the stateassociated with the URI
©2010 - Cesare Pautasso 42
DataFlow
Data Flow(Copy)
©2010 - Cesare Pautasso 43
©2010 - Cesare Pautasso 44
Myth: RESTful Web services cannot be composed (with BPEL) because they do not give a static contract description Reality: RESTful Web services can
dynamically negotiate the most suitable representation format with their clients Challenge: How to support dynamic
typing and content type negotiation in a BPM composition language?
Static vs. Dynamic Typing
©2010 - Cesare Pautasso 45
Myth: Processes cannot be mapped to resources because they can change their state (independently of their clients) Reality: REST Resources do not have to
be passive “CRUD” services but can be active and have a life of their own. Challenge: How to best let clients
control an active resource backed up by a process instance through the uniform interface?
Active Resources
©2010 - Cesare Pautasso 46
Myth: Processes run for a long time and need to interact asynchronously with their clients. This cannot be done with HTTP. Reality: HTTP supports non blocking
interactions. Each process instance is mapped to a resource URI, which can be used by clients throughout its lifetime. Challenge: How to let processes send
notifications back to their clients?
Synchronous vs. Asychronous
©2010 - Cesare Pautasso 47
REST resources are a good abstraction to publish processes on the Web RESTful HTTP is good enough to
interact without any extension with process execution engines and drive the execution of process and task instances If done right, BPM can be a great
modeling tool for Hypermedia-centric service design(and implementation!)
Conclusions
©2010 - Cesare Pautasso 48
More Information
Cesare PautassoFaculty of Informatics, USI Luganohttp://www.pautasso.info/@pautasso
JOperaRESTful Process Enginehttp://www.jopera.org/@jopera_org
© 49
R. Fielding, Architectural Styles and the Design of Network-based Software Architectures, PhD Thesis, University of California, Irvine, 2000
C. Pautasso, O. Zimmermann, F. Leymann, RESTful Web Services vs. Big Web Services: Making the Right Architectural Decision, Proc. of the 17th International World Wide Web Conference (WWW2008), Bejing, China, April 2008
C. Pautasso, BPEL for REST, Proc. of the 7th International Conference on Business Process Management (BPM 2008), Milano, Italy, September 2008
C. Pautasso, Composing RESTful Services with JOpera,In: Proc. of the International Conference on Software Composition (SC2009), July 2009, Zurich, Switzerland.
References
©2010 - Cesare Pautasso 50
Applying the SOA composition principle to REST gives interesting results Thanks to hyperlinks, REST brings a new
(more dynamic and loosely coupled) twist to SOA composition Composing RESTful services helps to build
mashups, but is different A RESTful API is the perfect abstraction for
publishing the state of a workflow
Conclusion
Raj Balasubramanian, Benjamin Carlyle, Thomas Erl, Cesare Pautasso, SOA with REST, Prentice Hall, to appear in 2011