Message-ID: <706709141.91.1425395064767.JavaMail.email@example.com> Subject: Exported From Confluence MIME-Version: 1.0 Content-Type: multipart/related; boundary="----=_Part_90_1037815725.1425395064767" ------=_Part_90_1037815725.1425395064767 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Content-Location: file:///C:/exported.html
This demonstration shows how the proposed servlet 3.0 asynchronous API (= inspired by Jetty continuations) can be used to greatly improve web service= s. The demo runs searches using the eBay API, both sync= hronously and asynchronously, and displays the results side-by-side.=20
The synchronous servlet calls the web service for each keyword sequentia= lly. The thread servicing the web request blocks, waiting for each search t= o complete before making the next request. The servlet thread is held for t= he entire elapsed time of all web service calls.=20
The asynchronous servlet uses the Jetty HTTP Client to initiate an asynchronous web service call f= or all keywords in parallel. As each search completes, its results are adde= d to the list of search results using a callback method. After all searches= have been completed, the request is resumed. The web service calls are don= e in parallel and the servlet thread is only held for a short time at the s= tart and end of the elapsed time.=20
With one item, the time it takes to fetch the search results is roughly = equivalent for both synchronous and asynchronous calls. However, with each = additional items, the time it takes to search using the synchronous servlet= increases proportionally, while the asynchronous servlet incurs only minor= additional overhead.=20
To run the demonstration, first get the source code from SVN. Run it using= =20 =20
then visit http://localhost:8080/. There are two examples each of s= ynchronous and asynchronous; the first example searches for one item, the s= econd for multiple.=20
You can also use the form at the bottom of the page to run your own sear= ches. For more dramatic results, try conducting a search with ten different= items at once.