You are currently browsing the tag archive for the ‘cometd’ tag.
The entire application took less than an hour to put together, which I think is a testament to the quality of the Bayeux implementation present in both Jetty and Dojo. [...] Comet is probably about 90% of the way to being usable for mainstream project.
So I have decided to give it a go in my new experimental monitoring project and got a core feature working – a RESTish webservice being able to publish and cache a message and retrieve the latest message from the cache on top of Comet in Jetty and Dojo. Bayeux’s channel names are used as URIs in REST and keys in the cache.
First, I have replicated the demo into a webapp war and deployed it in tomcat 6.0, in which process I have learnt how it works more in details. Basically what I need is to deploy a Jetty’s Continuation Servlet, which does all server side magic for you.
The most difficult part so far was hooking the caching function into the Jetty Cometd Servlet. First, I tried DataFilter, but I can’t get the real channel id as I use a wildcard channel “/**”. It always returns the root channel “/”. Next, I tried BayeuxService used in the echo demo, but it does not allow to subscribe a wildcard channel. So I ended up adding a simple server side client which updates the cache on deliver method in Listener interface.
The RESTish webservice servlet, mapped to /galaxy/*, serves the only 2 methods, the HTTP GET to return the last Bayeux’s JSON message on the channel named by getPathInfo() and the HTTP POST to publish posted data onto the channel named by getPathInfo(). For example,
At client side I use jQuery with Dojo and its color animations to notify a changed value by changing the background colors. It loads the initial data by getJSON on the galaxy servlet and updates the data by cometd subscriber.
So far so good.