users@glassfish.java.net

Re: Using EJBs in CometHandler (GlassFish 2 UR2)

From: <glassfish_at_javadesktop.org>
Date: Mon, 21 Jul 2008 03:44:22 PDT

> Hahahahaha for a moment I was ready to agree, but ...
> Let's say you are
> inside an EJB and you do:
>
> CometContext ctx =
> CometEngine.getEngine().getCometContext("blabla");
> CometHandler handler = ctx.getCometHandler(...);
> handle.attach(myEbjObjectOrWhateverObject);
> ....
>
> It gives you a unified way to pass object to the
> handler without the
> needs to downcast the handler.

OK, but you can also pass objects using notify(). All my handler logic is triggered by the onEvent method, so I haven't felt the need for attach yet. In my case, there would be race conditions if I would call attach() and then notify(), because multiple Message-Driven-Beans might access the CometContext at the same time.

Another question about Comet in JEE context came up with the CometEngine. Looking at the code of getEngine reveals it's a classic singleton and I wonder how it behaves in a clustered environment. Let's say the CometHandler is dynamically created in a servlet on server A along with context named "abc". Next, a MDB on server B wants to notify this context ("abc"). What will happen? Without a JEE-aware comet implementation, my speculation is that server B does not even know context "abc"?
[Message sent by forum member 'markusoj' (markusoj)]

http://forums.java.net/jive/thread.jspa?messageID=288022