You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mina.apache.org by "Newcomb, Michael-P57487" <Mi...@gdc4s.com> on 2006/09/06 19:18:04 UTC

IoHandler: messageSent and messageReceived

There is only one Thread (aka Worker) physically
reading/writing/accepting on the channel?

If that is true, then (for a given IoSession) I'm guaranteed that
IoHandler.messageSent will be called before any other operation occurs
on the channel?

I think IoHandler.messageSent is supposed to behave like this, but I
wanted to be sure that if I implement a request/response protocol that I
would never have to worry about a response to a message being received
before the IoHandler.messageSent call was made... So that when
IoHandler.messageSent is called, I can register the message as 'awaiting
response' or something like that...

Thanks,
Michael

Re: IoHandler: messageSent and messageReceived

Posted by Trustin Lee <tr...@gmail.com>.
On 9/7/06, Newcomb, Michael-P57487 <Mi...@gdc4s.com> wrote:
>
> There is only one Thread (aka Worker) physically
> reading/writing/accepting on the channel?
>
> If that is true, then (for a given IoSession) I'm guaranteed that
> IoHandler.messageSent will be called before any other operation occurs
> on the channel?
>
> I think IoHandler.messageSent is supposed to behave like this, but I
> wanted to be sure that if I implement a request/response protocol that I
> would never have to worry about a response to a message being received
> before the IoHandler.messageSent call was made... So that when
> IoHandler.messageSent is called, I can register the message as 'awaiting
> response' or something like that...


It's guarenteed because MINA fires messageSent event as soon as the write
finishes.  No more than one thread will process one session, so you will not
read any data while you write data.  But you can still get messageReceived
event if a remote peer wrote other message than the response message.

HTH,
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