Design and Implementation of an Asynchronous Invocation Framework for Web Services Uwe Zdun Markus Voelter Michael Kircher [email protected] [email protected] [email protected] The International Conference on Web Services - Europe 2003 (ICWS-Europe’03), Erfurt, Germany, Sep 2003. 1 Overview • Synchronous vs. asynchronous communication • Asynchronous invocation of Web Services • Client Asynchrony Patterns • Simple Asychronous Invocation Framework for Web Services Uwe Zdun, Vienna University of Economics 2 Synchronous vs. Asynchronous Communication • Synchronous communication in remote object frameworks: • The client wants to reach a Remote Object • It invokes a Client Proxy in the client process that handles network com- munication • The client blocks until the Client Proxy returns the result from the Remote Object invocation • Asychronous communication in remote object frameworks: • The client also invokes a Client Proxy, but ... • The Client Proxy returns to the client immediately and handles the remote invocation on its own • Different variants how to pass the result (and exceptions) back to the client (see asynchrony patterns). Uwe Zdun, Vienna University of Economics 3 Asynchronous Invocation of Web Services • Asynchronous invocations are an important functionality in the context of distributed object frameworks: • jitter and network latency make remote invocation times unpredictable • in many situations clients should not block during remote invocations • loose coupling between clients and remote services • Popular web service implementations (such as Apache Axis) offer only synchronous invocations (over HTTP) or messaging protocols • Client asynchrony can be built on top of synchronous invocation frame- work → Asynchrony Patterns • This is tedious and error-prone → Simple Asychronous Invocation Framework for Web Services Uwe Zdun, Vienna University of Economics 4 Client Asynchrony Patterns • A pattern describes a recurring solution to a problem in a context bal- ancing a set of forces: • Patterns cover the problem that expertise is hard to convey • Pattern Languages: no pattern is used in isolation → patterns are used as elements of a language • Four patterns for client asynchrony from a larger pattern language for OO Remoting • Full pattern language in forthcoming book “Remoting Patterns” by Markus Voelter, Michael Kircher, Uwe Zdun, and Michael Englbrecht to be published in Wiley’s Pattern Series in 2004. Uwe Zdun, Vienna University of Economics 5 Client Asynchrony Patterns: Fire and Forget/Sync with Server • Fire and Forget: • A Remote Object should be notified and a result is not required • Reliability is not critical • Client Proxy sends invocation and returns to the client immediately • It does not wait for a notification • Sync with Server: • A Remote Object should be notified and a result is not required • The invocation should be performed reliably • Client Proxy sends invocation and returns to the client immediately • It waits for an acknowledgment Uwe Zdun, Vienna University of Economics 6 Client Asynchrony Patterns: Poll Object/Result Callback • Poll Object: • An operation should be invoked asynchronously and a result is required • The client is able to decide when to use the returned result • Poll Objects receive the result of remote invocations on behalf of the client • The client subsequently uses the Poll Object to query the result • Result Callback • An operation should be invoked asynchronously and a result is required • The client needs to react immediately on incoming results • The client passes a Result Callback object to the Client Proxy • For arriving results the Client Proxy calls the predefined callback operation Uwe Zdun, Vienna University of Economics 7 Alternatives for Applying the Patterns Client Result Acknowledgment Responsiblity asynchrony to client to client for result pattern Fire and Forget no no - Sync with Server no yes - Poll Object yes yes Client is responsible for getting the result Result Callback yes yes Client is informed via a callback Uwe Zdun, Vienna University of Economics 8 Simple Asynchronous Invocation Framework for Web Services • Framework that realizes the asynchrony patterns on top of syn- chronous invocations • Works with Apache Axis on top of HTTP • Can be downloaded from: saiws.sourceforge.net Uwe Zdun, Vienna University of Economics 9 Client Proxies Invocation is performed using a Client Proxy. Synchronous invocations: SyncClientProxy scp = new SyncClientProxy(); String result = (String) scp.invoke(endpointURL, operationName, null, rt); Asynchronous invocation: AsyncHandler ah = ...; Object clientACT = ...; AsyncClientProxy ascp = new asyncClientProxy(); ... ascp.invoke(ah, clientACT, endpointURL, operationName, null, rt); Uwe Zdun, Vienna University of Economics 10
Description: