Conversation-based specification and composition of agent services Bao Quoc Vo (joint work with Lin Padgham) Intelligent Agent Groups RMIT University Conversation • A Web service conversation involves maintaining some state during an interaction that involves multiple messages and/or participants. • From Web Services Glossary (2004-02-11) Conversations and protocols 1: requestTransaction 2: enterPIN Customer 3: authorised 4: requestTransfer ATM Protocol models • Perspective – Global (cooperative) vs. service-centric – The latter usually requires less constraints on protocol compatibility • Formalism – Sequence diagrams – FSMs/statecharts – Process-based models • Expressive power Conditions, State management, Correlation, Transactions, Modularization, Exception handling, etc. Our model of WS/agent services • A service is an event-driven component – events are sending and receiving of messages • service description (external schema) comprises – external interface – system dynamics (interaction protocol): <S> : <dir><msg> <S> • <S> is the symbolic name of a state; • <dir> is the direction of the message (?/!) • <msg> is the message name Example (an online banking system) Service Banking { Interface { RECEIVE enterPIN(Account acc, EncryptedPIN PIN); RECEIVE requestTransfer(Account toAcc, float amount); RECEIVE requestBalance(); SEND invalidPIN(); SEND authorised(); SEND overdrawn(); SEND transactionApproved(); SEND currentBalance(float balance); }; Protocol { States { 0(init,final), 1, 2, 3, 4, 5(final), 6(final) }; Transitions { 0 : ?enterPIN -> 1; 1 : !invalidPIN -> 0; 1 : !authorised -> 2; 2 : ?requestTransfer -> 4; 2 : ?requestBalance -> 3; 3 : !currentBalance -> 0; 4 : !transferApproved -> 5; 4 : !overdrawn -> 6; }; }; }; Example (2) Service Composition • A composition system consists of the external schema of the target service plus the external schemata of the available component services, C = (ST, {S1, …, Sn}) • The composition problem: constructing the internal model of the target service so that it employs only messages of the component services and satisfies the interaction protocols. • Well-defined compositions: free of deadlocks and unspecified receptions. Service Composition (2) • A realisation of a composite service ST within a composition system (ST, {S1, …, Sn}) is a FSM M = (Q,Σ, δ, q0, F) • Informally, M simulates the behaviour of ST as follows: – The states in ST are mapped to a subset of states of M. – Each receive message m in ST is simulated in M originated from the corresponding state(s) of M. – Each send message m in ST corresponds to a subgraph G of M that implements the transactions needed to produce the data carried by m. The final transactions in G are also labelled m pointing to the corresponding state(s) of M. Service Composition (3) • The following will be interacting with M: the components services S1, …, Sn and a well-defined client which is a complement of ST (denoted C(ST)). • During execution of the composite service, the whole machinery M = (M,<S1, …, Sn ,C(ST)>) moves together through the composition states, producing execution traces; all execution traces comprise execution tree T. • Unspecified reception: A node on T where either M sends out a message m and none of S1, …, Sn ,C(ST) is in a state to receive m, or one of S1, …, Sn ,C(ST) is in a state of not receiving any message and only sending out a message m and M is not in a state to receive m. • Free of deadlock: All finite branches on T end at a composition state containing only final states of M, S1, …, Sn ,C(ST). Service Composition (4) • A realisation M = (Q,Σ, δ, q0, F) of a composition system C is an internal model of C if M is free of unspecified receptions and free of deadlocks. • Theorem: Checking whether a realisation M is an internal model of a given composition system C is poly-time. Asynchronous communication • Under a synchronous semantics, the finitestate machines describing the protocols of the component services and the internal model of the composite service are required to advance atomically. • To allow asynchronous communication, FIFO channels containing messages exchanged between different components of the system are introduced. Asynchronous communication (2) • A machinery M now contains also the communication medium state of the systems (i.e. the content of the FIFO channels) • A configuration consists of the composition state and the medium state. • Deadlock and unspecified receptions are accordingly defined. Synthesising composition • Ontological reasoning: mapping between component interfaces • Example: – – – – – ATS :: requestFlight.flightID AL :: flightRequest.flightID AL :: pricingInfo.price ATS :: offer.price forward AL :: flightUnavailable as ATS :: notAvailable forward ATS :: ack as AL :: bookFlight ATS :: requestFlight.flightID AL :: bookFlight.flightID Synthesising composition (2) • Constructing execution tree: exploring all possible execution traces given the finite state machines of the component services and the target service • error nodes on the execution trees: corresponding to states in which a deadlock or unspecified reception might arise. (Theorem 2 in the paper.) Conclusion • We tackling the problem of service composition in both the synchronous and asynchronous communication cases. • Given the specifications of the component services and the target service, we construct the internal model for the target service satisfying desirable properties. • Failure handling and allowing services to effect the physical world is the future work.