On 02/08/2011 10:37 PM, ilya goberman wrote:
> Alexey, I already described my requirements in previous posts: I want
> to write Comet infinite HTTP responses to each connected client
> individually (based on client's subscription requests). I do NOT want
> to write to ALL clients based on subscription topics. If you look at
> Tomcat/Comet: http://tomcat.apache.org/tomcat-6.0-doc/aio.html, this
> is what I want to replace.
Ok, in this case looks like client subscription should be a separate
topic (CometContext).
> You replied to me and recommended using Grizzly 2.0 with asynchronous
> HTTP API and look at the sample:
> http://java.net/projects/grizzly/sources/svn/content/branches/2dot0/code/samples/http-server-samples/src/main/java/org/glassfish/grizzly/samples/httpserver/nonblockinghandler/NonBlockingHttpHandlerSample.java
>
> 1) I installed Glassfish fine. The next step is to install Grizzly 2.0
> and this is where I get confused. Is Grizzly 2.0 already integrated
> with 3.1 Glassfish, I do not need to do anything, but I suspect it is
> not. So how do I install Grizzly 2.0 into Glassfish 3.1?
From your 1st email, I understood you want to serve just comet and
static content, and servlet container is not must, that's why I proposed
standalone Grizzly 2.0 and its HTTP suspend/resume mechanism.
If you need servlet container - then Glassfish 3.1 web profile would be
better choice (with Grizzly 1.9.x, which is integrated there).
You won't have a chance to control low-level write queue, but if your
CometHandlers will extend DefaultConcurrentCometHandler - you'd be able
to control comet events queue, which should do what you need.
>
> 2) Next I need to configure "asynchronous HTTP API". Is it the same as
> configuring "Comet API" per
> http://download.oracle.com/docs/cd/E19798-01/821-1752/ggrla/index.html, or
> it is something different?
It's what you may need in order to configure Glassfish 3.1 comet
support, it's not related to Grizzly 2.0.
Here is also a quote from another thread, which may help you configure
asynchronous CometHandler event processing:
>> 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);
> We set the thread pool as you suggest, but we also had to
> - make our VideoCometHandler extend DefaultConcurrentCometHandler
> and not just implement CometHandler interface.
>
> - call DefaultNotificationHandler.setSpreadNotifyToManyToThreads(true)
> method for the
> CometContext's NotificationHandler (see our diff).
>
> 5.23 <https://hg.imavis.com/centrepoint-trunk/rev/461661f6b26d#l5.23> CometContext context = engine.getCometContext(topic);
> 5.24 <https://hg.imavis.com/centrepoint-trunk/rev/461661f6b26d#l5.24> if (context == null) {
> 5.25 <https://hg.imavis.com/centrepoint-trunk/rev/461661f6b26d#l5.25> context = engine.register(topic);
> 5.26 <https://hg.imavis.com/centrepoint-trunk/rev/461661f6b26d#l5.26> + context.setBlockingNotification(false);
> 5.27 <https://hg.imavis.com/centrepoint-trunk/rev/461661f6b26d#l5.27> + DefaultNotificationHandler nh =
> 5.28 <https://hg.imavis.com/centrepoint-trunk/rev/461661f6b26d#l5.28> + (DefaultNotificationHandler) context.getNotificationHandler();
> 5.29 <https://hg.imavis.com/centrepoint-trunk/rev/461661f6b26d#l5.29> + nh.setSpreadNotifyToManyToThreads(true);
> 5.30 <https://hg.imavis.com/centrepoint-trunk/rev/461661f6b26d#l5.30> context.setExpirationDelay(-1);
> 5.31 <https://hg.imavis.com/centrepoint-trunk/rev/461661f6b26d#l5.31> VideoSource videoSource = createVideoSource(req.getPathInfo(), context);
> 5.32 <https://hg.imavis.com/centrepoint-trunk/rev/461661f6b26d#l5.32> context.addAttribute("videoSource", videoSource);
>
> 3) If I look at the sample
> http://java.net/projects/grizzly/sources/svn/content/branches/2dot0/code/samples/http-server-samples/src/main/java/org/glassfish/grizzly/samples/httpserver/nonblockinghandler/NonBlockingHttpHandlerSample.java,
> I see the lines below:
> // create a basic server that listens on port 8080.
> final HttpServer server = HttpServer.createSimpleServer();
>
> Does it imply that Grizzly listens on separate port then web
> container? I want my static web pages to be served on the same server
> port as Grizzly requests.
The sample is not actual, the complete servlet container functionality
is only provided by Glassfish.
Thanks.
Alexey.
> Thanks
>
>
> > Date: Tue, 8 Feb 2011 21:58:19 +0100
> > From: oleksiy.stashok_at_oracle.com
> > To: users_at_grizzly.java.net
> > Subject: Re: Want to migrate from Tomcat Comet to grizzly comet
> >
> > If you need a servlet container - it'd make sense to use Glassfish (I'd
> > recommend the latest 3.1 RC, with the latest Grizzly integrated). The
> > web profile, as Justin mentioned, should be enough.
> >
> > Here are instructions [1] how comet should be enabled on GF.
> >
> > Grizzly comet samples are here [2].
> >
> > I remember you asked about CometContext-per-Client, not sure it's good
> > idea :(
> > If you can describe your usecase, may be we can discuss better approach.
> >
> > Thanks.
> >
> > WBR,
> > Alexey.
> >
> > [1]
> http://download.oracle.com/docs/cd/E19798-01/821-1752/ggrla/index.html
> > [2]
> >
> http://java.net/projects/grizzly/sources/svn/show/trunk/code/samples/comet
> >
> > On 02/08/2011 07:43 PM, goberman_at_msn.com wrote:
> > > Alexey, I looked at docbook documentation last week. It shows how to
> > > run a standalone Java sample that is configured to listen on port 80
> > > for incoming connection requests.
> > > I am looking for a way to integrate grizzly with a "servlet
> container",
> > > like Tomcat (or Glassfish) and I am struggling to fund any
> > > documentation addressing it.
> > > It should confirm to the following requirements:
> > >
> > > 1) Server port should be configured in the "servlet container", not in
> > > grizzly. Grizzly should be "plugged into" container.
> > > 2) I should be able to serve both static web pages and handle HTTP
> > > Comet requests via Grizzly on the same server port. This is what
> > > Tomcat/Comet allows me to do now. I do not want to serve web pages on
> > > port X and Grizzly requests on port Y.
> > >
> > > Any chance of a quick guide on how to accomplish it? Or it is not
> > > possible?
> >