 |
Comet support in GlassFish
Posted by jfarcand on February 22, 2008 at 07:39 AM | Comments (6)
Want to learn how to write and deploy a web application based on GlassFish's Comet? Four little steps to surf the Comet's tail...
Download GlassFish Download the latest v2 ur1 version here. Read then installation guide here. From now I will use ${glassfish.home} to reference your installation directory. Enable Comet support in GlassFish By default, Comet support in not enabled in GlassFish. Why? Because two years ago it was hard for me to convince my co-workers about the new Comet revolution. But things has changed now, and you can even spend days reading on Comet. To enable Comet in GlassFish, just do: ${glassfish.home}/bin/asadmin set server.http-service.http-listener \
.http-listener-1.property.cometSupport=true
or
$ vi ${glassfish.home}/domains/domain1/config/domain.xml
add the following bold line under the http-listener port 8080
<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>
Comet in Action You are now ready to see what Comet does. Just deploy one of the following war file (save the war under ${glasfish.home}/domains/domain/autodeploy): Start two browsers, hits the application url (ex: http://localhost:8080/jmaki-comet/) and see real time updates executed from one browser on the second one!
Wow, I want to write tons of Comet applications, where do I start Take a look at the iFrame example or the javascript Prototype example as a start, and browse more documentation here. Ask questions using the users@glassfish.dev.java.net!
technorati: comet ajax glassfish icefaces dwr jmaki
Bookmark blog post: del.icio.us Digg DZone Furl Reddit
Comments
Comments are listed in date ascending order (oldest first) | Post Comment
-
Hello,
thanks a lot for this article.
It seems that the WebMC url is not working.
Also concerning the simple chat application do you know why it is using polling every 20 seconds with GET, I was hopping to see more of the comet like implementation.
Posted by: srenou on February 26, 2008 at 04:51 AM
-
Thanks for the broken link. I've asked Ted an alternate link. You can still see the WebMc demo live. As for the Chat, it use long polling like described here. If you want http streaming, try the jmaki demo. Long polling is also considered as part of Comet :-)
Posted by: jfarcand on February 26, 2008 at 06:46 AM
-
A fresh copy of webmc.war has been uploaded. The HTTP requests you see every 20 seconds are from the ICEfaces heartbeat; for mission critical applications, this allows you to know that the server has not gone offline in the last 20 seconds. Ajax Push updates occur independently of the heartbeat mechanism (that is why it is not a polling implementation). (The heartbeat interval can be configured, and for some applications you may prefer to simply turn it off.)
Posted by: tedgoddard on February 27, 2008 at 02:59 PM
-
Thanks for the updates.
Concerning those different comet complaint implementation, how are you able to identify what a proxy allows (long polling, streaming) and what kind of issues can be seen with proxies?
Posted by: srenou on March 17, 2008 at 07:37 AM
|