users@glassfish.java.net

Re: Using EJBs in CometHandler (GlassFish 2 UR2)

From: Jeanfrancois Arcand <Jeanfrancois.Arcand_at_Sun.COM>
Date: Mon, 21 Jul 2008 15:28:04 -0400

Salut,

glassfish_at_javadesktop.org wrote:
>> 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"?

You are right. There where a question a couple of days ago about that
specific issue. Inside a cluster, you need a mechanism to make sure all
CometContext are created on all instances:

+ When instance A creates CometContext abc, abc can be published to
other instance via JMS/Shoal/etc. *or* since most of the time the
CometContext can be created when the Servlet.init() in invoked, then
putting in web.xml <load-on-startup>0</load-on-startup> will take care
of creating the CometContext for all instance.

+ Uses the NotificationHandler to push notification amongs instance.
This is described here:

http://www.nabble.com/Re:-Grizzly-Comet-in-clustered-enviroment-tt18262063.html

Hope that help.

A+

-- Jeanfrancois



> [Message sent by forum member 'markusoj' (markusoj)]
>
> http://forums.java.net/jive/thread.jspa?messageID=288022
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>