You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Next »

Since a servlet is blocking, a normal HTTP communication makes the thread wait. So there is a possibility that all the threads in the pool can be used up. By using the asynchronous http client framework, the thread can be released back into the pool and be made available for other purposes until the answer comes back. When the answer comes back, a callback is fired which then relays the response back to the client.

The async http client is to be used in conjunction with webcontainers that are configured for non blocking communication. CometProcesor with Tomcat and Continuation with Jetty are some good examples. This example uses Tomcat.

About this example.

This example seeks to demonstrate the usage of the async http client by first configuring the Geronimo server. It then deploys an app which we shall call http-local-app on this configured server.  Another webapp call http-remote-app is deployed on any other server. The servlet on the http-local-app delegates requests to the async http client and returns immediately. The async http client connects to the remote app and when it recieves a response, a callback is fired which relays the message back to the original response stream.

 Configuring the server.

Install a geronimo server with tomcat webcontainer and start it. Log onto the console by using system/manager as your credentials. Click on the "Web Server" link on the left hand navigation frame. Under "Add new:" section, click on "Tomcat NIO HTTP connector".  Specify a uniquename for the connector and take all the default values. Save this configuration. Your new connector must be listed on the Network Listeners.

  • No labels