Design a Web service for an asynchronous, document-style process and describe how to refactor a Web service from a synchronous to an asynchronous model.

[Note]
  • [BLUEPRINTS] Chapter 8 - Application Architecture

Refactoring Synchronous to Asynchronous Interactions

Sometimes your application requires an asynchronous Web Service interaction. Web Services that use asynchronous interactions tend to be more responsive and scale better. However, Web Services provide only a synchronous mode of operation, especially when using the HTTP protocol. In your application you can convert this synchronous interaction to an asynchronous request and reply. You may be able to refactor some of the synchronous interactions of a Web Service application to asynchronous interactions.

Figure below illustrates a synchronous interaction. Notice how the client must suspend its processing until the service completes processing of the request and returns a response.

Synchronous Communication

On the other hand, with the asynchronous interaction, the client continues its processing without waiting for the service. In both the synchronous and asynchronous communication figures, the vertical lines represent the passage of time, from top to bottom. The vertical rectangular boxes indicate when the entity (client or service) is busy processing the request or waiting for the other entity to complete processing. In figure below, the open arrowhead indicates asynchronous communication and the dashed vertical line indicates that the entity is free to work on other things while a request is being processed.

Asynchronous Communication

When a component makes a synchronous call to another component, the calling component must wait for the receiving component to finish its processing. If the calling component instead makes the call asynchronously, the caller can proceed with its own work without waiting for the receiving component to do its job.

Below is the list of steps which need to be done to convert a synchronous endpoint to an asynchronous endpoint:

Converting from Synchronous to Asynchronous Communication

The JMS queue stores the messages until the message-driven beans are ready to process them, thereby controlling the rate of delivery. Thus, the component can process the messages without being overwhelmed, which helps the service to scale better.

Professional hosting     Belorussian informational portal         Free SCWCD 1.4 Study Guide     Free SCDJWS 1.4 Study Guide     SCDJWS 1.4 Quiz     Free IBM Certified Associate Developer Study Guide     IBM Test 000-287. Enterprise Application Development with IBM WebSphere Studio, V5.0 Study Guide     SCDJWS 5.0 Quiz