users@grizzly.java.net

Re: HTTP server with server-side push (COMET)

From: Evgeny Shepelyuk <eshepelyuk_at_gmail.com>
Date: Thu, 06 Aug 2009 16:56:15 +0300

Hello Alexey,

Although it might sound ridicously i don't have a luck with my project
usign 1.9 branch with comet extension.
I was able to implement server side push, but seems as it's working in
blockign mode.
I was running project in profiler and when i'm launching N clients - many
threads are immediately created by project.
And threads don't disappear after i kill clients' connections.

I'm attaching my Grizzly-1.9 based code

Thanks for your help.

> Hi Evgeny,
>
> documentation is not our strong side, unfortunately :(
> You can take a look to this unit test [1] specifically test name
> testSuspendNoArgs();
>
> You can find there how we suspend a HTTP connection and then, after some
> time send bytes and resume it.
> So, in your case you can just not resume HTTP connection, so it will
> stay suspended forever.
>
> In the example you may see, that we use StreamWriter to send a response
> back:
> res.getStreamWriter().writeXXX(...);
>
> the StreamWriter could be set to work either in blocking or non-blocking
> mode. When working in non-blocking mode, Grizzly uses async queue, which
> could be useful for you, though you've to be careful with memory
> consumption in this case :)
>
> If you'll have any other questions - please ask.
>
> WBR,
> Alexey.
>
> [1]
> https://grizzly.dev.java.net/source/browse/grizzly/branches/2dot0/code/modules/http/src/test/java/com/sun/grizzly/web/ArpSSLTest.java?view=markup
>
>> I have questions regarding implementation of my project.
>> Recently i decided to use Grizzly as a base for my HTTP server.
>> But after quite long looking into docs I can't understand how i can
>> resolve my problem.
>>
>> Let me describe my project requrements.
>>
>>
>> The idea is to buld application that serves media to relative big number
>> clients (more >500).
>> The specific features of clients' request are HTTP long-living nature.
>> So once connected client permanently fetches content from server.
>> Because simultaneous number of clients is high the blocking
>> thread-per-request model is not appropriate.
>>
>> Our current approach consist of following steps and based on SRP.
>> It's working OK but can't hold many connections.
>>
>> 1. client connects to endpoint, it has access to client's output stream
>> 2. endpoint has blocking queue inside it and registers that queue in
>> media
>> manager
>> to be notified about media events that should be streamed to underlying
>> client.
>> 3. HTTP connection should not break and be permanent -> client should
>> never disconnect after it got connected to server.
>> 4. inside endpoint in a loop look i'm performing blocking get from
>> blocking queue to receive event from media manager
>> that should be written to client's stream.
>>
>> So i've downloaded Grizzly 2.0.0-M3 and trying to write my NIO project.
>> I was able to build simple HTTP server using GrizzlyWebServer class, and
>> creating simple GrizzlyAdapter to server dummu content.
>> But i'm unable to figure out how to build asynchronous HTTP write.
>>
>> Should i somehow use package com.sun.grizzly.asyncqueue ?
>> Or maybe comet extension but comet is not available for 2.0.0-M3
>> Or my task can be impleneted by leveraging AsyncFilter but i can't
>> understand from tutorials how to implement pereodical asynchronous write
>> to client
>> without blocking thread.
>>
>> Can anyone give me advice on solving my problem.
>>
>>
>> --Regards,
>> Evgeny Shepelyuk
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail:
>> users-unsubscribe_at_grizzly.dev.java.net
>> For additional commands, e-mail:
>> users-help_at_grizzly.dev.java.net
>>



-- 
Regards,
Evgeny Shepelyuk