Hi Luis, On 7/22/07, Luis Neves <[EMAIL PROTECTED]> wrote:
Hello all. I think I'm misunderstanding something fundamental about how the IoSession.suspendRead() and IoSession.resumeRead() methods work and I would appreciate any insight you guys can offer. I have a producer and consumer both based on Mina. What I want to achieve is to block the producer while the the consumer is still processing the message. The way I thought I could do this was do something like this in the producer side: [...] WriteFuture wf = ioSession.write(message); wf.awaitUninterruptibly(); [...] and in the consumer side: public void messageReceived(IoSession iosession, Object message) throws Exception { long readMsg = iosession.getReadMessages(); iosession.suspendRead(); [... slow message processing ...] iosession.resumeRead(); } I was under the impression that the iosession.suspendRead() would make the producer block, but this is not the behaviour I'm seeing. What I'm seeing is that the even with the IoSession in suspend state the producer manages to successfully write the messages and the iosession.getReadMessages() in the consumer side keeps getting bigger. Are my expectations wrong? Is there any way I can achieve the desired behaviour with Mina?
suspend/resumeRead() is an asynchronous operation. It means message can be received *after* suspendRead() is called. However, once suspension request is processed by SocketIoProcessor, no more message will be received. Do we need TrafficFuture or something similar for more fine-grained control? Trustin -- what we call human nature is actually human habit -- http://gleamynode.net/ -- PGP Key ID: 0x0255ECA6