Thanks Oleksiy,
If I register a write handler and the queue is empty, will the handler
get triggered at that point i.e. no writes have taken place yet.
From the code it looked like it was only triggered once a successful
write had taken place, then the queue size is checked (processAsync,
write API's).
Thanks,
Dave.
On 04/11/15 23:52, Oleksiy Stashok wrote:
> Hi Dave,
>
> the maxAsyncWriteQueueSizeInBytes and WriteHandler are related. The
> WriteHandler, once registered, will be called (just once) when the
> queue size is less than the max, so you can perform
> connection.write(...).
>
>
> On 03.11.15 06:43, Dave wrote:
>>
>> When I dug into the code I seen in order to use this I would have to
>> register a WriteHandler via the notifyCanWrite(...) API. This is
>> triggered after the queue has been serviced i.e. at least one packet
>> must be written to the queue.
> You don't have to write any packet to make your WriteHandler to be
> triggered, these two things are not related.
>
>> However, I would like a way to determine at the time I write to the
>> queue whether the queue is full or not and take action at that point
>> in time.
> connection.canWrite() is probably what you're looking for.
>
> canWrite/notifyWritePossible methods are declared in OutputSink
> interface, which is implemented by Grizzly Connection, additionally
> this interface is implemented by HTTP Server's NIOOutputStream, which
> you can get from HTTP Response object passed to your HttpHandler.
>
>
> WBR,
> Alexey.
>
>>
>> One solution is to pass in a completionHandler when I call write on
>> the Connection. I can then keep track of the number of outstanding
>> packets (or bytes) outside the grizzly framework and on each write
>> check if I have exceeded my configured size and then take th
>> appropriate action.
>>
>> Can I get a brief explanation of how "maxAsyncWriteQueueSizeInBytes"
>> is intended to work and if I have missed anything that can give me
>> what I want within the grizzly framework.
>>
>> Thank you,
>> Dave.
>>
>>
>