You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@mina.apache.org by gil alvarez <tu...@gmail.com> on 2011/06/30 18:49:43 UTC

message ordering and threading

Hi, have a question about message ordering. I want to insure that messages
are received in order by my application.

I'm using mina on the client, as well as on the server, so i want to insure
that if the client sends message M1 followed by M2, that the server receives
M1 followed by M2; specifically, that the SessionHandler receives calls on
the same thread for the same IoSession.

The server is a multi-processor box, so i configure the acceptor with N
threads, since there may be multiple sessions involved.

So if on the client i do (in the same thread):

session.write( msg1 );
session.write( msg2 );

Am i correct in assuming that the SessionHandler will receive the messages
in order (on the same thread)?

There are really 2 questions here: will the mina layer on the client push
msg1 through the socket first, then msg2; and then will the server receive
them in order.

Thx.

Re: message ordering and threading

Posted by Emmanuel Lecharny <el...@gmail.com>.
On 6/30/11 6:49 PM, gil alvarez wrote:
> Hi, have a question about message ordering. I want to insure that messages
> are received in order by my application.
>
> I'm using mina on the client, as well as on the server, so i want to insure
> that if the client sends message M1 followed by M2, that the server receives
> M1 followed by M2; specifically, that the SessionHandler receives calls on
> the same thread for the same IoSession.
>
> The server is a multi-processor box, so i configure the acceptor with N
> threads, since there may be multiple sessions involved.
>
> So if on the client i do (in the same thread):
>
> session.write( msg1 );
> session.write( msg2 );
>
> Am i correct in assuming that the SessionHandler will receive the messages
> in order (on the same thread)?
>
> There are really 2 questions here: will the mina layer on the client push
> msg1 through the socket first, then msg2; and then will the server receive
> them in order.

There are two answers.

First, assuming you have not configured anything specific in MINA (like 
added an ExecutorFilter), the messages will be sent and received in 
order. The reason is that we associated one single IoProcessor per 
session, so every message belonging to a session will be processed one 
after the other by one unique thread.

Now, if you have added an ExecutorFilter, that will be a different 
story, unless you used an OrderedExecutorFilter.

Hope it helps.


-- 
Regards,
Cordialement,
Emmanuel Lécharny
www.iktek.com