users@grizzly.java.net

Re: Grizzly 2.X Comet VS response.suspend

From: Oleksiy Stashok <oleksiy.stashok_at_oracle.com>
Date: Tue, 14 Jun 2011 14:01:10 +0200

On 06/13/2011 07:58 PM, wild wrote:
> Ok, I've looked at the code and it seems that comet interfaces has not
> changed. So I can use my existing comet code that simply create an handler
> and call the write method on the response (right) ?
Yes.

> Now that writes are asynchronous, is it safe to call the flush method ?
Yes, flush just flushes any data buffered in the response output stream.

> What is happening if the write queue is full ? Should I handle an exception
> like you said for HttpServer ?
Yes, PendingWriteQueueLimitExceededException is going to be thrown on
queue overload.
Probably there is no much sense to handle it, because connection will be
closed by that time. Though it's up to you for sure.

> Is it possible that the momery growth a lot before grizzly find out that the
> client is disconnected ?
It's not just about disconnected clients, but for example clients which
read data slowly (may be on purpose).
Anyways, you can set the max async write queue size per Connection:

         final HttpServer server = new HttpServer();
         final NetworkListener listener =
                 new NetworkListener("Grizzly",
                                     NetworkListener.DEFAULT_NETWORK_HOST,
                                     PORT);
*listener.setMaxPendingBytes(MAX_SIZE);*
         server.addListener(listener);

Thanks.

WBR,
Alexey.