Using Asynchrony to Enable Long-Running Operations

A typical non-distributed software application uses synchronous methods between application components. The caller of a synchronous method is blocked from further execution until the method returns. Web services, however, run over networks. The distributed nature of applications using web services introduces unpredictable and sometimes very long latency, meaning the time it takes a particular operation to complete may be long. Some business processes represented by web services may involve human interaction at the back end, meaning an operation may take on the order of days. If all web service interactions were synchronous, each client with an outstanding operation would be consuming resources on its host system for unacceptably long periods of time.

WebLogic Workshop provides facilities that make it easy for you to build asynchronous web services. Using these facilities, you can design web services that don't require clients to block execution waiting for results. You can choose from multiple approaches for returning results to your web service's clients.

# Topics Included in This Section

Asynchronous Web Services

You can build web services that allow a client to initiate a request, then receive notification from your web service at a later time when results are ready. This is accomplished by using callbacks. You can also simulate an asynchronous web service by providing a polling interface to clients that cannot accept callbacks (see below).

Using Callbacks to Notify Clients of Events

Callbacks are used to notify a client of your web service that some event has occurred. For example, you may wish to notify a client when the results of that client's request are ready.

Asynchronous Methods

Asynchronous methods and callbacks return immediately to the caller, allowing the calling web service or application to continue other processing (or become dormant) until the result of the operation is complete. Asynchronous methods and callbacks are also referred to as being buffered, because the asynchrony is accomplished using message buffers. Buffering methods and callbacks can help your web services handle high loads.

Using Polling as an Alternative to Callbacks

Some clients of your web services may not be capable of handling callbacks. Callbacks are messages that your web service sends to the client, and many systems on which clients run are configured so that they will reject all "unsolicited" incoming traffic. In order to allow clients that operate in this environment to use your web services, you can supply a polling interface as an alternative. In a polling interface, you provide one or more methods that a client can call periodically to determine whether the result of a previous request is ready.

Related Topics

The Web Services Development Cycle

Maintaining State with Conversations

Conversation.jws Sample