Skip to main content

How to make Comet Extensible

3 replies [Last post]
sendtopms
Offline
Joined: 2004-11-23
Points: 0

I am currently proposing Architecture based on Comet on Glassfish for an enterprise application. One of the nice feature in GF is Comet. I looked at few comet samples like chat, echo etc on GF. My question how can I expose changes in other enterprise components, for example, ejb3.0 to be pushed to the client which uses Dojo cometd?
I did not find any extension point in com.sun.grizzly.cometd.servlet.CometdServlet! Is there any other way which I missed? I read through most comet related blogs but not able to find an answer for the above question. Basically I am looking for integration point using which I can hook messages from other entity componets which detect the data to be pushed to the client.

Please guide me on this. Expecting reply.

Thanks in Advance,
Senthilkumar.

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
writtmeyer
Offline
Joined: 2006-11-17
Points: 0

Did you read this blog entry?

http://weblogs.java.net/blog/jfarcand/archive/2006/07/the_grizzly_com.html

CometdServlet is an example of the usage of the relevant classes.

You should look specifically at CometHandler, CometEngine and CometContext. CometdServlet on the other hand should just be used as an example of how to use these classes.

Also have a look at the other blog entries by Jean Francois. They contain further information about Glassfish's/Grizzly's comet API.

--
Wolfram Rittmeyer

jfarcand
Offline
Joined: 2003-06-10
Points: 0

Grrr looks like when I reply using mail, the forum is not extended :-) I've been in touch with Senthilkumar and we will soon post (or blog) about how to extend Bayeux support from an EJB :-) Shing-Wai and I will update the forum once we have fully tested the solution :-)

A+

-- jeanfrancois

sendtopms
Offline
Joined: 2004-11-23
Points: 0

I got the solution with the help of JFA,
In short, The following snippet of code will enable to post/push message to channel in the Context.

String message = "<>";
String user = "<>";

HashMap map = new HashMap();
map.put("chat", message);
map.put("user", user);
Data data = new Data();
data.setMapData(map);
data.setChannel("/chat/demo");
data.setClientId("ejb6312");

CometEngine cometEngine = CometEngine.getEngine().getCometContext(contextPath).notify(data);

Note: HashMap and Data is a wrapper to create a bayeux message of the following form
/*[{"successful":true,"channel":"/chat/demo","timestamp":"Wed, 30 Apr 2008 15:43:34 GMT","id":"5"},{"id":"5","timestamp":"Wed, 30 Apr 2008 15:43:34 GMT","data":{"chat":"<>","user":"<>"},"channel":"/chat/demo"}]*/.

Please look at the below link for more details http://forums.java.net/jive/thread.jspa?messageID=272256&#272256

Thanks,
Senthilkumar PM