University of Lugano (USI)
Faculty of Informatics
Opened 2004
30 Professors
150+ PhD/Postdoc researchers
New Software Institute
New Master in Software and Data Engineering
Architecture, Design and Web Information Systems Engineering
BenchFlow - a benchmark for workflow engines
Liquid.js - Liquid Software Architecture
ASQ - Interactive Web Lectures
Parallel JavaScript/Multicore Node.JS
SAW - Collaborative Architectural Decision Making
NaturalMash - Web Service Composition with Natural Language
http://design.inf.usi.ch
Towards RESTful BPM
image/svg+xml
?
Database
Datamail
Decoupled Sharing
image/svg+xml
World Wide Web
PUT
GET
Database
Hypermedia
Discovery by Referral
image/svg+xml
World Wide Web
PUT
GET
Link
World Wide Web
PUT
GET
GET
Link
Software Connectors
image/svg+xml
Remote Procedure Call
Asynchronous Messaging
File Transfer
Shared Database
Stream
World Wide Web
The Web as a Software Connector
image/svg+xml
Send
Receive
PUT
GET
PUT
GET
GET
Send
Receive
image/svg+xml
PUT
GET
PUT
200
GET
200
image/svg+xml
PUT
GET
GET
PUT
DELETE
BP
image/svg+xml
Process Execution Engine
Process Designer
Process Model
Process Owner
Process Instance
Software Activities
Human Activities
image/svg+xml
Process Execution Engine
Software Activities
Human Activities
GET /R PUT /R DELETE /R POST /R
RESTful service composition
Process Model P
Process Instance P.1
GET /P/1 PUT /P/1 DELETE /P/1 POST /P/1
GET /P PUT /P DELETE /P POST /P
Publishing processes as resources
Conversations
RESTful Process Engine API
image/svg+xml
Process Model P
Process Instance P.1
GET /P/1 PUT /P/1 DELETE /P/1 POST /P/1
GET /P PUT /P DELETE /P POST /P
Task Instance P.1.T
GET /P/1/T PUT /P/1/T DELETE /P/1/T POST /P/1/T
Remote Process Call
POST /process/name HTTP/1.1
...after some time...
HTTP/1.1 200
Process Completed
Processes as Resources
Bookmark a process instance
Ask a process instance for links to its pending tasks
Drive the execution of tasks with PUT/POST/DELETE
Monitor processes using an RSS/ATOM feed
Fetch links to active, completed, failed process instances
Control which subset of tasks is actually exposed as resources
Resources as Processes
Publish resources from processes that drive their internal state transitions
Activate process control flow on requests routed to resources managed by processes
Produce responses from process data flow
Control the lifecycle of resources from the process model
Mint resource identifiers from process instances
Map resource identifiers to process instances
RESTful Process Engine API
Processes can be published as resources
Only the visible part of processes should be published as resources
Resource state transitions can be driven by process models
REST Architectural Elements
User Agent
Proxy
Gateway
Origin Server
Gateway
HTTP
Cache
image/svg+xml
User Agent
Origin Server
HTTP
image/svg+xml
User Agent
Proxy
HTTP
Origin Server
HTTP
Cache
image/svg+xml
Clients
Proxy
REST Service
Cache
REST middleware is primarily designed to scale a single server, which may need to service a large number of clients
image/svg+xml
Client
Composite REST Service
REST Services
A Composite REST service provides an aggregated view over the state of multiple REST services
image/svg+xml
GET /C PUT /C DELETE /C POST /C
GET /S PUT /S DELETE /S POST /S
GET /R PUT /R DELETE /R POST /R
The behavior of /C is defined by composing /R and /S
image/svg+xml
/C
/R
/S
The composite resource /C only aggregates the state of its components /R and /S
image/svg+xml
/C
/R
/S
The composite resource /C augments or caches the state of its components
image/svg+xml
GET /C PUT /C DELETE /C POST /C
GET /S PUT /S DELETE /S POST /S
GET /R PUT /R DELETE /R POST /R
image/svg+xml
GET /C PUT /C DELETE /C POST /C
GET /S PUT /S DELETE /S POST /S
GET /R PUT /R DELETE /R POST /R
image/svg+xml
GET /C PUT /C DELETE /C POST /C
GET /S PUT /S DELETE /S POST /S
GET /R PUT /R DELETE /R POST /R
Composing Representations with Hypermedia
image/svg+xml
/R
/S
Link
/S
Link
/R
C
The composite representation C refers to its component resources /R and /S via hyperlinks
image/svg+xml
REST Services
REST Services
Composite
Client
REST Service
C
Composite Representation
A composite representation is interpreted by the client that follows its hyperlinks and aggregates the state of the referenced component resources
A composite representation may be retrieved from a composite service
Example: DoodleMap
image/svg+xml
Google Maps
Doodle
Composite
Client
REST Service
C
Composite Representation
Yahoo! Local Search
Vote to choose a meeting place based on its geographic location
Composite REST Service
image/svg+xml
GET /C DELETE /C POST /C
GET /D PUT /D DELETE /D POST /D
GET /YLS
Compose Yahoo! Local Search with Doodle
Composite REST Service
image/svg+xml
GET /C DELETE /C POST /C
GET /D PUT /D DELETE /D POST /D
GET /YLS
Create a new poll using the locations
Composite Representation
image/svg+xml
/M
/C
Link
/C
Link
/M
C
/Y
/D
Link
/D
Demo
RESTful service composition
RESTful service composition extends the role of intermediary to aggregate multiple resources
Composite representations take advantage of hypermedia to shift some of the composition work (and state) to the client
RESTful compositions may be built using BPM (JOpera, BPEL/BPMN for REST)
The Context
image/svg+xml
RESTful API
Persistent Storage
Database 2
Backend 1
REST service logic
RESTful API
REST service logic
Backend 3
The Problem
image/svg+xml
GET
Client
PUT
Single state transfers from/to the client are idempotent
How do we make both interactions atomic?
Constraints
InteroperabilityNo changes/extensions to HTTP No additional verbs No special/custom headers
Loose CouplingREST services should remain unaware they are participating in a transaction
SimplicityTransactions will not be adopted in practice unless they can be made simple enough
Try-Confirm/Cancel
image/svg+xml
Try
Final State
Confirm
Initial State
Timeout
Reserved State
Cancel
TCC Participant's view
image/svg+xml
TCC service try confirm cancel
Database
Try : Insert into reservation db
Confirm : Update reservation, set status = confirmed
Cancel : Invalidate reservation
Timeout : Invalidate reservation
Try
POST /booking HTTP/1.1
Host: api.swiss.com
HTTP/1.1 201 Created
Location: /booking/{id}
Confirm
PUT /booking/{id} HTTP/1.1
Host: api.swiss.com
Accept: application/tcc
HTTP/1.1 204 No Content
Cancel
DELETE /booking/{id} HTTP/1.1
HTTP/1.1 204 No Content
TCC Example
image/svg+xml
Phone No Service
Booking Process
Billing Service
1. bookPhoneForCustomer
1.1 R1 = reserveNumber
1.2 R2 = billCustomer
Transaction Coordinator
1.3 confirmAll (R1, R2)
1.3.1 confirm(R1)
1.3.2 confirm(R2)
Failure before Confirm
image/svg+xml
Phone No Service
Booking Process
Billing Service
1. bookPhoneForCustomer
2.2 Timeout
2.1 Timeout
1.1 R1 = reserveNumber
1.2 R2 = billCustomer
ATOMIC All participants timeout
Failure after Confirm
image/svg+xml
Phone No Service
Booking Process
Billing Service
1. bookPhoneForCustomer
1.1 R1 = reserveNumber
1.2 R2 = billCustomer
Transaction Coordinator
1.3 confirmAll (R1, R2)
1.3.1 confirm(R1)
1.3.2 confirm(R2)
ATOMIC All participants confirmed
Failure during Confirm
image/svg+xml
Phone No Service
Booking Process
Billing Service
1. bookPhoneForCustomer
1.1 R1 = reserveNumber
1.2 R2 = billCustomer
Transaction Coordinator
1.3 confirmAll (R1, R2)
1.3.1 RETRY confirm(R1)
1.3.2 RETRY confirm(R2)
ATOMIC All participants (eventually) confirmed
Timeout during Confirm
image/svg+xml
Phone No Service
Booking Process
Billing Service
1. bookPhoneForCustomer
1.1 R1 = reserveNumber
1.2 R2 = billCustomer
Transaction Coordinator
1.3 confirmAll (R1, R2)
1.3.1 confirm(R1)
2.2 Timeout
1.3.2 confirm(R2) ERROR!
HEURISTIC EXCEPTION
Timeout?
POST /booking/ HTTP/1.1
Host: api.swiss.com
HTTP/1.1 200 OK
Content-Type: application/json
{"participantLink":
{ "uri":"http://api.swiss.com/booking/{id}",
"expires" :"2014-04-07T10:15:54.261+01:00",
"rel":"tcc" }
}
After a Timeout
PUT /booking/{id} HTTP/1.1
Host: api.swiss.com
Accept: application/tcc
HTTP/1.1 404 Not Found
Participants indicates confirmation link expired
Workflow
Try to reserve multiple resources
POST /telephone HTTP/1.1
Host: api.swisscom.ch
HTTP/1.1 201 Created
Location: /telephone/0586664302
POST /bill HTTP/1.1
Host: api.post.ch
HTTP/1.1 201 Created
Location: /bill/42
If everything is successful, confirm the bookings
PUT /telephone/0586664302 HTTP/1.1
Host: api.swisscom.ch
Accept: application/tcc
HTTP/1.1 204 No Content
PUT /bill/42 HTTP/1.1
Host: api.post.ch
Accept: application/tcc
HTTP/1.1 204 No Content
Workflow
Try to reserve multiple resources
POST /booking HTTP/1.1
Host: api.swisscom.ch
HTTP/1.1 201 Created
Location: /telephone/0586664302
POST /bill HTTP/1.1
Host: api.post.ch
HTTP/1.1 500 Internal Server Error
Incorrect billing address
If something fails, do nothing. The reserved resources will eventually timeout.
If something fails, a polite workflow would explicitly cancel the successful reservations
DELETE /telephone/0586664302 HTTP/1.1
Host: api.swisscom.ch
HTTP/1.1 200 OK
Conclusion: REST/TCC
Multi-party RESTful Conversation Pattern
Try-Confirm/Cancel applicable to reservation-based business models
Fits really well with REST design constraints (Hypermedia, Uniform Interface, Statelessness)
We are looking for early adopters that need transactions across their RESTful APIs
References
Cesare Pautasso, Ana Ivanchikj, and Silvia Schreier, A Pattern Language for RESTful Conversations, EuroPlop 2016 Ana Ivanchikj, Cesare Pautasso, and Silvia Schreier, Visual modeling of RESTful conversations with RESTalk , Journal of Software & Systems Modeling, pp. 1-21, May, 2016. F. Haupt, F. Leymann, C. Pautasso: A conversation based approach for modeling REST APIs , 12th Working IEEE / IFIP Conference on Software Architecture (WICSA 2015), Montreal, CA, May 2015
G. Hohpe, RESTful Conversations , 15 March 2015
G. Hohpe, "Let's have a conversation", Internet Computing, IEEE 11.3 (2007): 78-81.
Roy Fielding, Architectural Styles and the Design of Network-based Software Architectures , University of California, Irvine, 2000
G. Pardon and C. Pautasso, Atomic Distributed Transactions: a RESTful Design , 5th International Workshop on Web APIs and RESTful Design (WS-REST), Seoul, Korea, ACM, April, 2014.
Jim Webber, Savas Parastatidis, Ian Robinson, REST in Practice: Hypermedia and Systems Architecture, O'Reilly, 2010
Cesare Pautasso, Erik Wilde, Push-Enabling RESTful Business Processes , 9th International Conference on Service Oriented Computing (ICSOC 2011), Paphos, Cyprus, December 2011
Cesare Pautasso, BPMN for REST , In Proceedings of the 3rd International Workshop on BPMN (BPMN 2011), Lucerne, Switzerland, November 2011
Thomas Erl, Benjamin Carlyle, Cesare Pautasso, Raj Balasubramanian, SOA with REST: Principles, Patterns & Constraints for Building Enterprise Solutions with REST , Prentice Hall, 2012
Acknowledgements
Frank Leymann, Olaf Zimmermann, Florian Haupt, Silvia Schreier, Ana Ivanchikj, Guy Pardon, Mathias Weske, Adriatik Nikaj, Sankalita Mandal, Hagen Overdick, Jesus Bellido, Rosa Alarcón, Alessio Gambi, Daniele Bonetta, Achille Peternier, Erik Wilde, Mike Amundsen, Stefan Tilkov
Use a spacebar or arrow keys to navigate