On 5/4/12 9:23 AM, marcelloraffaele_at_gmail.com wrote:
> Hi,
> i'm developing an application using filter chain for protocol
> management ( like GIOP example).
> I have now some others thinks to ask:
> - how to manage timeouts: the problem is that when i write a message in
> handleWrite, i receive the ack in handleRead, how i can develop a timer
> that fire me if i don't receive ack in a performant way? Is there
> something to do this in grezzly? I think that i should use greezzly
> thread for timeout.
You may be able to use use the standard IdleTimeoutFilter and pass a custom
DelayedExecutor.Worker<Connection>.
See the DefaultWorker [1] in IdleTimeoutFilter for a sample implementation.
> - Is there a way for filters to listen event? if a timeout fire, i need
> to ask to my filter to write a message. How i can do it in Grizzly
> framework?
Take a look at:
- Filter.handleEvent(FilterChainContext, FilterChainEvent) [2]
- FilterChainContext.notify{Upstream,Downstream} [3]
> - how i can control the number of connections that the server manage?
> what i need to set?
Grizzly currently doesn't have a mechanism to enforce connection limits.
It wouldn't be hard to create a Filter that trace the number of
connections using the
onConnect() callback.
[1]
http://grizzly.java.net/nonav/docs/2.2/xref/org/glassfish/grizzly/utils/IdleTimeoutFilter.html
[2]
http://grizzly.java.net/nonav/docs/2.2/xref/org/glassfish/grizzly/filterchain/Filter.html
[3]
http://grizzly.java.net/nonav/docs/2.2/xref/org/glassfish/grizzly/filterchain/FilterChainContext.html