Hi,
My first try on controlling the incomming message rate was something like
this (server IoHandler):
public void messageReceived(final IoSession session, Object message) {
//business message processing ...
session.suspendRead();
Executors.newSingleThreadScheduledExecutor().schedule(new Runnable()
{
public void run() {
session.resumeRead();
}
},1000, TimeUnit.MILLISECONDS);
}
This was supposed to limit the incoming message rate at 1/sec.
The first message was received and the first suspendRead() suspended the
messageReceived callbacks.
But after 1 second when resumeRead was issued, the messageReceived callback
rate was out of control meaning that the second suspendRead had no effect,
the messages kept pouring in.
Regards,
Horia
On 2/7/07, Trustin Lee <[EMAIL PROTECTED]> wrote:
Hi Horia,
On 2/5/07, Horia Muntean <[EMAIL PROTECTED]> wrote:
>
> Hello,
>
> After further study I think I found a way to disconnect a slow client.
> IoSession.getScheduledWritesRequests() should give me the number of
> pending messages that were not yet written to the remote peer, so if this
> number exceeds a certain threshold I could issue IoSession.close().
True.
As far as controlled incoming message rate is concerned I experimented a
> little with IoSession.suspendRead() but I found out it will not do. I
> mean the first suspendRead is doing what it says but after the first
> resumeRead the incomming messages rate can't be controlled. So, do you think
> I could file a RFE on Jira about this issue? Or is there a possible solution
> with the current framework?
You could suspend again as rate increases. suspending and resuming
continuously will do the trick, no?
Trustin
--
what we call human nature is actually human habit
--
http://gleamynode.net/
--
PGP key fingerprints:
* E167 E6AF E73A CBCE EE41 4A29 544D DE48 FE95 4E7E
* B693 628E 6047 4F8F CFA4 455E 1C62 A7DC 0255 ECA6