users@grizzly.java.net

Re: CometContext blocked by client

From: Oleksiy Stashok <oleksiy.stashok_at_oracle.com>
Date: Mon, 07 Feb 2011 14:22:46 +0100

Hi,

please try to assign a thread pool to CometEngine, to be able to run
handlers asynchronously like:

         final CometEngine engine = CometEngine.getEngine();

         ThreadPoolConfig tpConfig = ThreadPoolConfig.DEFAULT.clone()
                 .setCorePoolSize(2)
                 .setMaxPoolSize(5)
                 .setQueueLimit(256);
         GrizzlyExecutorService ges =
GrizzlyExecutorService.createInstance(tpConfig);

         engine.setThreadPool(ges);


WBR,
Alexey.

PS: assume startComet method is somehow synchronized? ;)

> we are using your Grizzly 1.9.31 "Full Embedded Server" for our server.
> We are providing video or events stream to clients via a Comet Service.
>
> For each client request a new CometHandler is added to the CometContext,
> that is created when the first request is received.
> We use the following code:
>
>
> /void startComet(HttpServletRequest req, HttpServletResponse res) {
> String topic = req.getRequestURI();
> CometEngine engine = CometEngine.getEngine();
> CometContext context = engine.getCometContext(topic);
> if (context == null) {
> context = engine.register(topic);
> context.setExpirationDelay(-1);
> context.setBlockingNotification(false);
> VideoSource videoSource =
> createVideoSource(req.getPathInfo(), context);
> context.addAttribute("videoSource", videoSource);
> videoSource.start();
> }
> MultipartCometHandler handler = new MultipartCometHandler(topic);
> handler.attach(res);
> context.addCometHandler(handler);
> }/
>
> where MultipartCometHandler class implements CometHandler.
>
>
> When some new frame or event comes up, the VideoSource notifies the
> CometContext with the /CometContext.notify(Object obj)/ method.
>
> We have noticed that if more than one client is connected to the
> CometContext, and for some reason one of them is blocked reading the
> socket
> (for example it halts on a breakpoint in test mode) all other clients
> halt too. When the blocking client restarts also the others do.
>
> We try to solve this problem setting blockingNotification parameter to
> /false/ via /CometContext.setBlockingNotification(false)/ method,
> but doesn't work.
>
> Are we doing some mistake? Is there a way to create non blocking comet
> contexts?
>
> Thanks for support
> Regards
>
> --
> Leonardo Pecile
> ImaVis S.r.l.
> Via F.lli Carpigiani, 4
> 40138 - Bologna - Italy
> phone: + 39 051 6012120
> fax: +39 051 531666
> web:www.imavis.com
> email:leonardo.pecile_at_imavis.com