Skip to main content

Running AsyncWeb in GlassFish

Posted by jfarcand on July 21, 2006 at 10:47 AM PDT

AsyncWeb, the high-throughput non blocking Java HTTP engine who support asynchronous request processing from POJO objects, can now run on top of Grizzly, the http engine used by GlassFish.

AsyncWeb can now be deployed in GlassFish. AsyncWeb is (from the site):

AsyncWeb (built on top of the excellent Mina network framework) employs 
non-blocking selector driven IO at the transport level, and is
asynchronous thoughout - from the initial parsing of requests,
right through to and including the services implemented by users.
AsyncWeb breaks away from the blocking request / response architecture
found in todays popular HTTP engines. This allows it to be highly
scalable and capable of supporting very high throughput - even in high
processing latency scenarios. A simple API allows new asynchronous
services to be created easily - and out-of-the-box Spring integration
allows hem to be configured simply and with great flexibility.
In addition to "endpoint" HTTP services, AsyncWeb also
allows configurable "chains" of behaviour - nabling "filter"
like behaviour to be applied to all requests. Pluggable "resolvers"
map incoming requests to their target HTTP service - and are given
access to the entire incoming request - allowing the routing
possibilities to be very lexible.

Looks promising, does it? A couple of weeks ago I've started working with Dave Irving, the man behind AsyncWeb, exploring ways to run AsyncWeb on top of Grizzly, the NIO framework used in GlassFish. The technical challenge to makes this happens was to replace, under the hood, the dependencies with MINA.

The good news is that both MINA and AsyncWeb are extremely well designed, and it was easy (without having to change anything inside AsyncWeb*), to run AsyncWeb on top of the Grizzly framework.

Technically, Grizzly receives requests, read |write the bytes and delegate the processing to AsyncWeb, by implementing the MINA interfaces AsyncWeb rely on. Doing the work, I've realized how easy is to build an NIO application on top of MINA. I've implemented one interface and used one MINA wrapper et voila! Note that extending Grizzly is also simple, but lack of available tutorials like MINA make it harder to use (subliminal message for myself...write docs! :-)).

Surprisingly, the code required to run AsyncWeb on top of Grizzly consist of only three classes. The code can be found here.

OK, enough bla bla bla bla bla and let see how it to deploy AsyncWeb in GlassFish. Dont't run away! Dave and I will make the integration much simpler over the next couple of weeks, but for peoples interested now :-), just follow the steps below.

Deploying AsyncWeb in GlassFish

First, install GlassFish by following the steps here. Make sure you get a nightly build released after July 21. Next, get the latest AsyncWeb binary here. Unzip the AsyncWeb bundle. You will get:

4 -rw-r--r--  1 jfarcand jfarcand 3514 May 22 08:10 build.xml
4 drwxr-xr-x  4 jfarcand jfarcand 4096 May 22 08:10 conf
4 drwxr-xr-x  4 jfarcand jfarcand 4096 May 22 08:10 docs
4 drwxr-xr-x  4 jfarcand jfarcand 4096 May 22 08:10 examples
4 drwxr-xr-x  2 jfarcand jfarcand 4096 May 22 08:10 lib

Copy the content under lib/* to your glassfish installation:

% cp -R lib/* ${glassfish.home}/lib

GlassFish doesn't ship (for now) the Grizzly extension required to enable AsyncWeb. Download the extension here, and unzip the jar file under your GlassFish lib directory:

% cd ${glassfish.home}
% unzip asyncweb-grizzly.jar

Finally, tell GlassFish to listen for AsyncWeb requests by adding, in GlassFish's domain.xml, the following line:

        <http-listener acceptor-threads="1" address="0.0.0.0" 
blocking-enabled="false" default-virtual-server="server" enabled="true"
family="inet" id="http-listener-1" port="8080" security-enabled="false"
server-name="" xpowered-by="true">
          <property name="selectorThreadImpl"
    value="com.sun.grizzly.asyncweb.AsyncWebSelectorThread"
/>

This will enable AsyncWeb to listen on port 8080. You are now ready to test the installation by starting GlassFish:

% ${glassfish.home}/bin/asadmin start-domain

and from your browser, issue http://localhost:8080 and see:

Async.jpg

Stay tuned. We will significantly improve the installation steps in the upcoming weeks, and start exploring ways to bundle AsyncWeb's Service with Web Application. We will also explore ways to make use of Grizzly Comet via an AsyncWeb Service!

(*) Ok, only one change in AsyncWeb...make a method public instead or protected

technorati:

Related Topics >>