Tuesday, 23 October 2007
Scalable Ajax Push with ICEfaces and GlassFish Grizzly Comet
ICEfaces now has preliminary integration with GlassFish Grizzly Comet. You can download a recent nightly GlassFish build and ICEfaces 1.7DR2 to try it out.
Ajax Push (aka "Comet") allows applications to update the web page independently of user events, but to do so, a connection must remain open from the server to the browser. This connection is used to notify the browser of the page updates to apply. Unfortunately, if standard Java Servlets implement the notification mechanism, a scalability problem arises: one thread for each user becomes blocked in the Servlet.service() method. Grizzly solves this problem with asynchronous request processing: using Java NIO, many requests and responses can be dealt with using a small thread pool. ICEfaces now makes use of these Grizzly features to provide Ajax Push without consuming a thread for each user. Special thanks goes out to Jean-Francois for all the hard work he put in helping us to integrate ICEfaces with Grizzly and GlassFish.
These features are not enabled by default. You will need to modify your ICEfaces web.xml to contain the following mapping as the first mapping (so that the GrizzlyPushServlet is the first match on the overlapping url-pattern):
<servlet>
<servlet-name>Grizzly Push Servlet</servlet-name>
<servlet-class>com.icesoft.faces.webapp.http.servlet.GrizzlyPushServlet</servlet-class>
<load-on-startup> 1 </load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Grizzly Push Servlet</servlet-name>
<url-pattern>/block/receive-updated-views/*</url-pattern>
</servlet-mapping>
Add the cometSupport property to your http-listener in (for example) domains/domain1/config/domain.xml:
<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="cometSupport" value="true"/>
</http-listener>
With those configuration changes, you have enabled scalable Ajax Push. This makes GlassFish and ICEfaces a powerful combination for building large-scale multi-user Ajax applications.
An easy way to get started is to try the .war file for the ICEfaces auction monitor
Technorati Tags: ajax ajaxpush comet glassfish icefaces jsf scalable servlet web20
Posted by at 2:50 PM in Entries by Ted Goddard
