You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mina.apache.org by tiandike <wh...@21cn.com> on 2007/10/22 06:39:31 UTC

why client received message in order?

I modified the example of echoserver  

in my code I disable the default ThreadModel setting and configure the
number of  I/O processor thread.


I don't understand why my client can receive the results in order?
Thanks!

the code and the result is below:

/////////////////////////////////
the main class is :
public class Main {
    /** Choose your favorite port number. */
    private static final int PORT = 8080;

    public static void main(String[] args) throws Exception {
    	int num = Runtime.getRuntime().availableProcessors() * 3;
        IoAcceptor acceptor = new SocketAcceptor(num,
Executors.newCachedThreadPool());
        IoAcceptorConfig config = new SocketAcceptorConfig();
        config.setThreadModel(ThreadModel.MANUAL);
        DefaultIoFilterChainBuilder chain = config.getFilterChain();
        chain.addLast("threadPool", new
ExecutorFilter(Executors.newCachedThreadPool()));
       
        acceptor.bind(new InetSocketAddress(PORT), new
EchoProtocolHandler1(),
                config);
        System.out.println("Listening on port " + PORT);
    }

}


/////////////////////////////////
EchoProtocolHandler1.java

public class EchoProtocolHandler1 extends IoHandlerAdapter {
	private static Random r=new Random();
	private static final Logger log = LoggerFactory
			.getLogger(EchoProtocolHandler.class);



	public void exceptionCaught(IoSession session, Throwable cause) {
		cause.printStackTrace();
		session.close();
	}

	public void messageReceived(IoSession session, Object message)
			throws Exception {
		if (!(message instanceof ByteBuffer)) {
			return;
		}
		Thread.currentThread().sleep(r.nextInt(1000));

		ByteBuffer rb = (ByteBuffer) message;
		// Write the received data back to remote peer
		ByteBuffer wb = ByteBuffer.allocate(rb.remaining());
		wb.put(rb);
		wb.flip();
		
	
		session.write(wb);
	}

}

////////////////////////////////////////////
and my client handler:

public class ClientHandler extends IoHandlerAdapter {
	
	private int num=0;
	
	public ClientHandler(int num){
		this.num=num;
	}
	

	@Override
	public void sessionOpened(IoSession session) throws Exception {
		
		for (int i = 0; i < num; i++) {
			session.write(String.valueOf(i));
			
		}
	}
	@Override
	public void messageReceived(IoSession session, Object message)
			throws Exception {

		System.out.println("messageReceived:"+message);
	}


}


//////////////////////////////////////////////
and ClientMain :

public class ClientMain {

	private static final String HOSTNAME = "localhost";
	private static final int PORT = 8080;

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		InetSocketAddress socketAddress = new InetSocketAddress(HOSTNAME, PORT);
		IoServiceConfig config = new SocketConnectorConfig();
		config.setThreadModel(ThreadModel.MANUAL);
		DefaultIoFilterChainBuilder chain = config.getFilterChain();

        chain.addLast("threadPool", new
ExecutorFilter(Executors.newCachedThreadPool()));
        
        int num=100;
        
        SocketConnector connector=new SocketConnector();
        
        ConnectFuture future = connector.connect(new InetSocketAddress(
                HOSTNAME, PORT), new ClientHandler(num), config);

        future.join();
        
  
	}

}
///////////////////////////////////////////////////////////////
in eclipse console:

messageReceived:0
messageReceived:1
messageReceived:2
messageReceived:3
messageReceived:4
messageReceived:5
messageReceived:6
messageReceived:7
messageReceived:8
messageReceived:9
messageReceived:10
messageReceived:11
messageReceived:12
messageReceived:13
messageReceived:14
messageReceived:15
messageReceived:16
messageReceived:17
messageReceived:18
messageReceived:19
messageReceived:20
messageReceived:21
messageReceived:22
messageReceived:23
messageReceived:24
........
messageReceived:99

-- 
View this message in context: http://www.nabble.com/why-client-received-message-in-order--tf4668688s16868.html#a13336726
Sent from the Apache MINA Support Forum mailing list archive at Nabble.com.


Re: why client received message in order?

Posted by leafsax <le...@hotmail.com>.
fireEvent only executes the event when the previous event is completed

I modified the example of echoserver  

in my code I disable the default ThreadModel setting and configure the
number of  I/O processor thread.
and in EchoProtocolHandler.messageReceived I insert the code:
Thread.currentThread().sleep(r.nextInt(1000));
...
-- 
View this message in context: http://www.nabble.com/why-client-received-message-in-order--tf4668688s16868.html#a13357935
Sent from the Apache MINA Support Forum mailing list archive at Nabble.com.


Re: why client received message in order?

Posted by leafsax <le...@hotmail.com>.
fireEvent only executes the event when the previous event is completed

-- 
View this message in context: http://www.nabble.com/why-client-received-message-in-order--tf4668688s16868.html#a13357935
Sent from the Apache MINA Support Forum mailing list archive at Nabble.com.


Re: why client received message in order?

Posted by tiandike <wh...@21cn.com>.


Trustin Lee wrote:
> 
> 
> As you see from the source code, there's an event buffer per session
> that maintains the message order.
> 
> 

I can't understand the detail,can you give a more detail explanation?
thanks

-- 
View this message in context: http://www.nabble.com/why-client-received-message-in-order--tf4668688s16868.html#a13378840
Sent from the Apache MINA Support Forum mailing list archive at Nabble.com.


Re: why client received message in order?

Posted by Trustin Lee <tr...@gmail.com>.
Yes.  The number of threads that handle the eventQueue in
SessionBuffer per session is at most 1 at the same time.  That's how
the message order is maintained.

HTH,
Trustin

On 10/26/07, tiandike <wh...@21cn.com> wrote:
>
> then the number of thread that handle eventQueue in SessionBuffer  for one
> connector(session?) is at most 1 at the same time?
>
>
> Trustin Lee wrote:
> >
> > On 10/25/07, tiandike <wh...@21cn.com> wrote:
> >>
> >> I debug the source code and find it's SessionBuffer  to maintain the
> >> order  ,
> >
> > True.
> >
> >> and i find one connection with one thread for handler (Thread
> >> [pool-4-thread-4] ).  Is this right?
> >
> > No.  Thread is allocated on a per-event basis.  If it's allocated per
> > session, we will have to create too many threads and won't scale.
> >
> > HTH,
> > Trustin
> > --
> > what we call human nature is actually human habit
> > --
> > http://gleamynode.net/
> > --
> > PGP Key ID: 0x0255ECA6
> >
> >
>
> --
> View this message in context: http://www.nabble.com/why-client-received-message-in-order--tf4668688s16868.html#a13423898
> Sent from the Apache MINA Support Forum mailing list archive at Nabble.com.
>
>


-- 
what we call human nature is actually human habit
--
http://gleamynode.net/
--
PGP Key ID: 0x0255ECA6

Re: why client received message in order?

Posted by tiandike <wh...@21cn.com>.
then the number of thread that handle eventQueue in SessionBuffer  for one
connector(session?) is at most 1 at the same time?


Trustin Lee wrote:
> 
> On 10/25/07, tiandike <wh...@21cn.com> wrote:
>>
>> I debug the source code and find it's SessionBuffer  to maintain the
>> order  ,
> 
> True.
> 
>> and i find one connection with one thread for handler (Thread
>> [pool-4-thread-4] ).  Is this right?
> 
> No.  Thread is allocated on a per-event basis.  If it's allocated per
> session, we will have to create too many threads and won't scale.
> 
> HTH,
> Trustin
> -- 
> what we call human nature is actually human habit
> --
> http://gleamynode.net/
> --
> PGP Key ID: 0x0255ECA6
> 
> 

-- 
View this message in context: http://www.nabble.com/why-client-received-message-in-order--tf4668688s16868.html#a13423898
Sent from the Apache MINA Support Forum mailing list archive at Nabble.com.


Re: why client received message in order?

Posted by Trustin Lee <tr...@gmail.com>.
On 10/25/07, tiandike <wh...@21cn.com> wrote:
>
> I debug the source code and find it's SessionBuffer  to maintain the order  ,

True.

> and i find one connection with one thread for handler (Thread
> [pool-4-thread-4] ).  Is this right?

No.  Thread is allocated on a per-event basis.  If it's allocated per
session, we will have to create too many threads and won't scale.

HTH,
Trustin
-- 
what we call human nature is actually human habit
--
http://gleamynode.net/
--
PGP Key ID: 0x0255ECA6

Re: why client received message in order?

Posted by tiandike <wh...@21cn.com>.
I debug the source code and find it's SessionBuffer  to maintain the order  ,
and i find one connection with one thread for handler (Thread
[pool-4-thread-4] ).  Is this right?



Trustin Lee wrote:
> 
> On 10/23/07, tiandike <wh...@21cn.com> wrote:
>>
>> in the source code of ExecutorFilter:
>> in function messageReceived : it call  fireEvent function.
>> this function  call  executor.execute(new ProcessEventsRunnable(buf));
>>
>> it will config multithread to execute the run function .
>>
>> in the run function of ProcessEventsRunnable  it call
>>
>> processEvent(event.getNextFilter(), buffer.session, event
>>                         .getType(), event.getData());
>>
>> in processEvent the code include
>> nextFilter.messageReceived(session, data);
>>
>> at last it will call the handler messageReceived.
>>
>> as you see processEvent is executed in multithread ,how to ensure "the
>> corresponding
>> IoHandler.messageReceived events will be called in the same order on the
>> server."??
> 
> As you see from the source code, there's an event buffer per session
> that maintains the message order.
> 
> HTH,
> Trustin
> -- 
> what we call human nature is actually human habit
> --
> http://gleamynode.net/
> --
> PGP Key ID: 0x0255ECA6
> 
> 

-- 
View this message in context: http://www.nabble.com/why-client-received-message-in-order--tf4668688s16868.html#a13400188
Sent from the Apache MINA Support Forum mailing list archive at Nabble.com.


Re: why client received message in order?

Posted by Trustin Lee <tr...@gmail.com>.
On 10/23/07, tiandike <wh...@21cn.com> wrote:
>
> in the source code of ExecutorFilter:
> in function messageReceived : it call  fireEvent function.
> this function  call  executor.execute(new ProcessEventsRunnable(buf));
>
> it will config multithread to execute the run function .
>
> in the run function of ProcessEventsRunnable  it call
>
> processEvent(event.getNextFilter(), buffer.session, event
>                         .getType(), event.getData());
>
> in processEvent the code include
> nextFilter.messageReceived(session, data);
>
> at last it will call the handler messageReceived.
>
> as you see processEvent is executed in multithread ,how to ensure "the
> corresponding
> IoHandler.messageReceived events will be called in the same order on the
> server."??

As you see from the source code, there's an event buffer per session
that maintains the message order.

HTH,
Trustin
-- 
what we call human nature is actually human habit
--
http://gleamynode.net/
--
PGP Key ID: 0x0255ECA6

Re: why client received message in order?

Posted by tiandike <wh...@21cn.com>.
in the source code of ExecutorFilter:
in function messageReceived : it call  fireEvent function.
this function  call  executor.execute(new ProcessEventsRunnable(buf));

it will config multithread to execute the run function .

in the run function of ProcessEventsRunnable  it call

processEvent(event.getNextFilter(), buffer.session, event
                        .getType(), event.getData());

in processEvent the code include
nextFilter.messageReceived(session, data);

at last it will call the handler messageReceived.

as you see processEvent is executed in multithread ,how to ensure "the
corresponding
IoHandler.messageReceived events will be called in the same order on the
server."??

thanks!




Maarten Bosteels-4 wrote:
> 
> By default, MINA preserves the order of all events for a particular
> IoSession.
> 
> When a client first sends msgA and then msgB, the corresponding
> IoHandler.messageReceived events will be called in the same order on the
> server.
> And the second messageReceived will not be called before the first one
> returned
> 
> Note that this is only true for one particular IoSession, messageReceived
> can be called simultaneously for different IoSessions.
> 
> If you want more parallel processing, have a look at
> http://issues.apache.org/jira/browse/DIRMINA-334
> 
> Maarten
> 
> 
> On 10/22/07, mat <fo...@gmail.com> wrote:
>>
>> Try client sends more than 100. Make it 100000 and see.
>>
>> On 10/22/07, tiandike <wh...@21cn.com> wrote:
>> >
>> >
>> > thougth my client  send some requests in one connector , the server
>> handle
>> > these request in mutithread.
>> > if the client send request b after request a ,but the server handle b
>> > faster than a  and in this condition can my client receive the response
>> b
>> > first?
>> >
>> >
>> >
>> > mat-29 wrote:
>> > >
>> > > I didn't see why NOT if in your client side only single thread
>> sending
>> > the
>> > > message.
>> > >
>> > > On 10/22/07, tiandike <wh...@21cn.com> wrote:
>> > >>
>> > >>
>> > >> I modified the example of echoserver
>> > >>
>> > >> in my code I disable the default ThreadModel setting and configure
>> the
>> > >> number of  I/O processor thread.
>> > >>
>> > >>
>> > >> I don't understand why my client can receive the results in order?
>> > >> Thanks!
>> > >>
>> > >> the code and the result is below:
>> > >>
>> > >> /////////////////////////////////
>> > >> the main class is :
>> > >> public class Main {
>> > >>    /** Choose your favorite port number. */
>> > >>    private static final int PORT = 8080;
>> > >>
>> > >>    public static void main(String[] args) throws Exception {
>> > >>        int num = Runtime.getRuntime().availableProcessors() * 3;
>> > >>        IoAcceptor acceptor = new SocketAcceptor(num,
>> > >> Executors.newCachedThreadPool());
>> > >>        IoAcceptorConfig config = new SocketAcceptorConfig();
>> > >>        config.setThreadModel(ThreadModel.MANUAL);
>> > >>        DefaultIoFilterChainBuilder chain = config.getFilterChain();
>> > >>        chain.addLast("threadPool", new
>> > >> ExecutorFilter(Executors.newCachedThreadPool()));
>> > >>
>> > >>        acceptor.bind(new InetSocketAddress(PORT), new
>> > >> EchoProtocolHandler1(),
>> > >>                config);
>> > >>        System.out.println("Listening on port " + PORT);
>> > >>    }
>> > >>
>> > >> }
>> > >>
>> > >>
>> > >> /////////////////////////////////
>> > >> EchoProtocolHandler1.java
>> > >>
>> > >> public class EchoProtocolHandler1 extends IoHandlerAdapter {
>> > >>        private static Random r=new Random();
>> > >>        private static final Logger log = LoggerFactory
>> > >>                        .getLogger(EchoProtocolHandler.class);
>> > >>
>> > >>
>> > >>
>> > >>        public void exceptionCaught(IoSession session, Throwable
>> cause)
>> > {
>> > >>                cause.printStackTrace();
>> > >>                session.close();
>> > >>        }
>> > >>
>> > >>        public void messageReceived(IoSession session, Object
>> message)
>> > >>                        throws Exception {
>> > >>                if (!(message instanceof ByteBuffer)) {
>> > >>                        return;
>> > >>                }
>> > >>                Thread.currentThread().sleep(r.nextInt(1000));
>> > >>
>> > >>                ByteBuffer rb = (ByteBuffer) message;
>> > >>                // Write the received data back to remote peer
>> > >>                ByteBuffer wb = ByteBuffer.allocate(rb.remaining());
>> > >>                wb.put(rb);
>> > >>                wb.flip();
>> > >>
>> > >>
>> > >>                session.write(wb);
>> > >>        }
>> > >>
>> > >> }
>> > >>
>> > >> ////////////////////////////////////////////
>> > >> and my client handler:
>> > >>
>> > >> public class ClientHandler extends IoHandlerAdapter {
>> > >>
>> > >>        private int num=0;
>> > >>
>> > >>        public ClientHandler(int num){
>> > >>                this.num=num;
>> > >>        }
>> > >>
>> > >>
>> > >>        @Override
>> > >>        public void sessionOpened(IoSession session) throws Exception
>> {
>> > >>
>> > >>                for (int i = 0; i < num; i++) {
>> > >>                        session.write(String.valueOf(i));
>> > >>
>> > >>                }
>> > >>        }
>> > >>        @Override
>> > >>        public void messageReceived(IoSession session, Object
>> message)
>> > >>                        throws Exception {
>> > >>
>> > >>                System.out.println("messageReceived:"+message);
>> > >>        }
>> > >>
>> > >>
>> > >> }
>> > >>
>> > >>
>> > >> //////////////////////////////////////////////
>> > >> and ClientMain :
>> > >>
>> > >> public class ClientMain {
>> > >>
>> > >>        private static final String HOSTNAME = "localhost";
>> > >>        private static final int PORT = 8080;
>> > >>
>> > >>        /**
>> > >>         * @param args
>> > >>         */
>> > >>        public static void main(String[] args) {
>> > >>                InetSocketAddress socketAddress = new
>> > >> InetSocketAddress(HOSTNAME, PORT);
>> > >>                IoServiceConfig config = new SocketConnectorConfig();
>> > >>                config.setThreadModel(ThreadModel.MANUAL);
>> > >>                DefaultIoFilterChainBuilder chain =
>> > config.getFilterChain
>> > >> ();
>> > >>
>> > >>        chain.addLast("threadPool", new
>> > >> ExecutorFilter(Executors.newCachedThreadPool()));
>> > >>
>> > >>        int num=100;
>> > >>
>> > >>        SocketConnector connector=new SocketConnector();
>> > >>
>> > >>        ConnectFuture future = connector.connect(new
>> InetSocketAddress(
>> > >>                HOSTNAME, PORT), new ClientHandler(num), config);
>> > >>
>> > >>        future.join();
>> > >>
>> > >>
>> > >>        }
>> > >>
>> > >> }
>> > >> ///////////////////////////////////////////////////////////////
>> > >> in eclipse console:
>> > >>
>> > >> messageReceived:0
>> > >> messageReceived:1
>> > >> messageReceived:2
>> > >> messageReceived:3
>> > >> messageReceived:4
>> > >> messageReceived:5
>> > >> messageReceived:6
>> > >> messageReceived:7
>> > >> messageReceived:8
>> > >> messageReceived:9
>> > >> messageReceived:10
>> > >> messageReceived:11
>> > >> messageReceived:12
>> > >> messageReceived:13
>> > >> messageReceived:14
>> > >> messageReceived:15
>> > >> messageReceived:16
>> > >> messageReceived:17
>> > >> messageReceived:18
>> > >> messageReceived:19
>> > >> messageReceived:20
>> > >> messageReceived:21
>> > >> messageReceived:22
>> > >> messageReceived:23
>> > >> messageReceived:24
>> > >> ........
>> > >> messageReceived:99
>> > >>
>> > >> --
>> > >> View this message in context:
>> > >>
>> >
>> http://www.nabble.com/why-client-received-message-in-order--tf4668688s16868.html#a13336726
>> > >> Sent from the Apache MINA Support Forum mailing list archive at
>> > >> Nabble.com
>> > >> .
>> > >>
>> > >>
>> > >
>> > >
>> >
>> > --
>> > View this message in context:
>> >
>> http://www.nabble.com/why-client-received-message-in-order--tf4668688s16868.html#a13338571
>> > Sent from the Apache MINA Support Forum mailing list archive at
>> Nabble.com
>> > .
>> >
>> >
>>
> 
> 

-- 
View this message in context: http://www.nabble.com/why-client-received-message-in-order--tf4668688s16868.html#a13356190
Sent from the Apache MINA Support Forum mailing list archive at Nabble.com.


Re: why client received message in order?

Posted by mat <fo...@gmail.com>.
How stupid I am. That should be the way messageReceived act, right?
Thanks.Maarten.

On 10/22/07, Maarten Bosteels <mb...@gmail.com> wrote:
>
> By default, MINA preserves the order of all events for a particular
> IoSession.
>
> When a client first sends msgA and then msgB, the corresponding
> IoHandler.messageReceived events will be called in the same order on the
> server.
> And the second messageReceived will not be called before the first one
> returned
>
> Note that this is only true for one particular IoSession, messageReceived
> can be called simultaneously for different IoSessions.
>
> If you want more parallel processing, have a look at
> http://issues.apache.org/jira/browse/DIRMINA-334
>
> Maarten
>
>
> On 10/22/07, mat <fo...@gmail.com> wrote:
> >
> > Try client sends more than 100. Make it 100000 and see.
> >
> > On 10/22/07, tiandike <wh...@21cn.com> wrote:
> > >
> > >
> > > thougth my client  send some requests in one connector , the server
> > handle
> > > these request in mutithread.
> > > if the client send request b after request a ,but the server handle b
> > > faster than a  and in this condition can my client receive the
> response
> > b
> > > first?
> > >
> > >
> > >
> > > mat-29 wrote:
> > > >
> > > > I didn't see why NOT if in your client side only single thread
> sending
> > > the
> > > > message.
> > > >
> > > > On 10/22/07, tiandike <wh...@21cn.com> wrote:
> > > >>
> > > >>
> > > >> I modified the example of echoserver
> > > >>
> > > >> in my code I disable the default ThreadModel setting and configure
> > the
> > > >> number of  I/O processor thread.
> > > >>
> > > >>
> > > >> I don't understand why my client can receive the results in order?
> > > >> Thanks!
> > > >>
> > > >> the code and the result is below:
> > > >>
> > > >> /////////////////////////////////
> > > >> the main class is :
> > > >> public class Main {
> > > >>    /** Choose your favorite port number. */
> > > >>    private static final int PORT = 8080;
> > > >>
> > > >>    public static void main(String[] args) throws Exception {
> > > >>        int num = Runtime.getRuntime().availableProcessors() * 3;
> > > >>        IoAcceptor acceptor = new SocketAcceptor(num,
> > > >> Executors.newCachedThreadPool());
> > > >>        IoAcceptorConfig config = new SocketAcceptorConfig();
> > > >>        config.setThreadModel(ThreadModel.MANUAL);
> > > >>        DefaultIoFilterChainBuilder chain = config.getFilterChain();
> > > >>        chain.addLast("threadPool", new
> > > >> ExecutorFilter(Executors.newCachedThreadPool()));
> > > >>
> > > >>        acceptor.bind(new InetSocketAddress(PORT), new
> > > >> EchoProtocolHandler1(),
> > > >>                config);
> > > >>        System.out.println("Listening on port " + PORT);
> > > >>    }
> > > >>
> > > >> }
> > > >>
> > > >>
> > > >> /////////////////////////////////
> > > >> EchoProtocolHandler1.java
> > > >>
> > > >> public class EchoProtocolHandler1 extends IoHandlerAdapter {
> > > >>        private static Random r=new Random();
> > > >>        private static final Logger log = LoggerFactory
> > > >>                        .getLogger(EchoProtocolHandler.class);
> > > >>
> > > >>
> > > >>
> > > >>        public void exceptionCaught(IoSession session, Throwable
> > cause)
> > > {
> > > >>                cause.printStackTrace();
> > > >>                session.close();
> > > >>        }
> > > >>
> > > >>        public void messageReceived(IoSession session, Object
> message)
> > > >>                        throws Exception {
> > > >>                if (!(message instanceof ByteBuffer)) {
> > > >>                        return;
> > > >>                }
> > > >>                Thread.currentThread().sleep(r.nextInt(1000));
> > > >>
> > > >>                ByteBuffer rb = (ByteBuffer) message;
> > > >>                // Write the received data back to remote peer
> > > >>                ByteBuffer wb = ByteBuffer.allocate(rb.remaining());
> > > >>                wb.put(rb);
> > > >>                wb.flip();
> > > >>
> > > >>
> > > >>                session.write(wb);
> > > >>        }
> > > >>
> > > >> }
> > > >>
> > > >> ////////////////////////////////////////////
> > > >> and my client handler:
> > > >>
> > > >> public class ClientHandler extends IoHandlerAdapter {
> > > >>
> > > >>        private int num=0;
> > > >>
> > > >>        public ClientHandler(int num){
> > > >>                this.num=num;
> > > >>        }
> > > >>
> > > >>
> > > >>        @Override
> > > >>        public void sessionOpened(IoSession session) throws
> Exception
> > {
> > > >>
> > > >>                for (int i = 0; i < num; i++) {
> > > >>                        session.write(String.valueOf(i));
> > > >>
> > > >>                }
> > > >>        }
> > > >>        @Override
> > > >>        public void messageReceived(IoSession session, Object
> message)
> > > >>                        throws Exception {
> > > >>
> > > >>                System.out.println("messageReceived:"+message);
> > > >>        }
> > > >>
> > > >>
> > > >> }
> > > >>
> > > >>
> > > >> //////////////////////////////////////////////
> > > >> and ClientMain :
> > > >>
> > > >> public class ClientMain {
> > > >>
> > > >>        private static final String HOSTNAME = "localhost";
> > > >>        private static final int PORT = 8080;
> > > >>
> > > >>        /**
> > > >>         * @param args
> > > >>         */
> > > >>        public static void main(String[] args) {
> > > >>                InetSocketAddress socketAddress = new
> > > >> InetSocketAddress(HOSTNAME, PORT);
> > > >>                IoServiceConfig config = new
> SocketConnectorConfig();
> > > >>                config.setThreadModel(ThreadModel.MANUAL);
> > > >>                DefaultIoFilterChainBuilder chain =
> > > config.getFilterChain
> > > >> ();
> > > >>
> > > >>        chain.addLast("threadPool", new
> > > >> ExecutorFilter(Executors.newCachedThreadPool()));
> > > >>
> > > >>        int num=100;
> > > >>
> > > >>        SocketConnector connector=new SocketConnector();
> > > >>
> > > >>        ConnectFuture future = connector.connect(new
> > InetSocketAddress(
> > > >>                HOSTNAME, PORT), new ClientHandler(num), config);
> > > >>
> > > >>        future.join();
> > > >>
> > > >>
> > > >>        }
> > > >>
> > > >> }
> > > >> ///////////////////////////////////////////////////////////////
> > > >> in eclipse console:
> > > >>
> > > >> messageReceived:0
> > > >> messageReceived:1
> > > >> messageReceived:2
> > > >> messageReceived:3
> > > >> messageReceived:4
> > > >> messageReceived:5
> > > >> messageReceived:6
> > > >> messageReceived:7
> > > >> messageReceived:8
> > > >> messageReceived:9
> > > >> messageReceived:10
> > > >> messageReceived:11
> > > >> messageReceived:12
> > > >> messageReceived:13
> > > >> messageReceived:14
> > > >> messageReceived:15
> > > >> messageReceived:16
> > > >> messageReceived:17
> > > >> messageReceived:18
> > > >> messageReceived:19
> > > >> messageReceived:20
> > > >> messageReceived:21
> > > >> messageReceived:22
> > > >> messageReceived:23
> > > >> messageReceived:24
> > > >> ........
> > > >> messageReceived:99
> > > >>
> > > >> --
> > > >> View this message in context:
> > > >>
> > >
> >
> http://www.nabble.com/why-client-received-message-in-order--tf4668688s16868.html#a13336726
> > > >> Sent from the Apache MINA Support Forum mailing list archive at
> > > >> Nabble.com
> > > >> .
> > > >>
> > > >>
> > > >
> > > >
> > >
> > > --
> > > View this message in context:
> > >
> >
> http://www.nabble.com/why-client-received-message-in-order--tf4668688s16868.html#a13338571
> > > Sent from the Apache MINA Support Forum mailing list archive at
> > Nabble.com
> > > .
> > >
> > >
> >
>

Re: why client received message in order?

Posted by Maarten Bosteels <mb...@gmail.com>.
By default, MINA preserves the order of all events for a particular
IoSession.

When a client first sends msgA and then msgB, the corresponding
IoHandler.messageReceived events will be called in the same order on the
server.
And the second messageReceived will not be called before the first one
returned

Note that this is only true for one particular IoSession, messageReceived
can be called simultaneously for different IoSessions.

If you want more parallel processing, have a look at
http://issues.apache.org/jira/browse/DIRMINA-334

Maarten


On 10/22/07, mat <fo...@gmail.com> wrote:
>
> Try client sends more than 100. Make it 100000 and see.
>
> On 10/22/07, tiandike <wh...@21cn.com> wrote:
> >
> >
> > thougth my client  send some requests in one connector , the server
> handle
> > these request in mutithread.
> > if the client send request b after request a ,but the server handle b
> > faster than a  and in this condition can my client receive the response
> b
> > first?
> >
> >
> >
> > mat-29 wrote:
> > >
> > > I didn't see why NOT if in your client side only single thread sending
> > the
> > > message.
> > >
> > > On 10/22/07, tiandike <wh...@21cn.com> wrote:
> > >>
> > >>
> > >> I modified the example of echoserver
> > >>
> > >> in my code I disable the default ThreadModel setting and configure
> the
> > >> number of  I/O processor thread.
> > >>
> > >>
> > >> I don't understand why my client can receive the results in order?
> > >> Thanks!
> > >>
> > >> the code and the result is below:
> > >>
> > >> /////////////////////////////////
> > >> the main class is :
> > >> public class Main {
> > >>    /** Choose your favorite port number. */
> > >>    private static final int PORT = 8080;
> > >>
> > >>    public static void main(String[] args) throws Exception {
> > >>        int num = Runtime.getRuntime().availableProcessors() * 3;
> > >>        IoAcceptor acceptor = new SocketAcceptor(num,
> > >> Executors.newCachedThreadPool());
> > >>        IoAcceptorConfig config = new SocketAcceptorConfig();
> > >>        config.setThreadModel(ThreadModel.MANUAL);
> > >>        DefaultIoFilterChainBuilder chain = config.getFilterChain();
> > >>        chain.addLast("threadPool", new
> > >> ExecutorFilter(Executors.newCachedThreadPool()));
> > >>
> > >>        acceptor.bind(new InetSocketAddress(PORT), new
> > >> EchoProtocolHandler1(),
> > >>                config);
> > >>        System.out.println("Listening on port " + PORT);
> > >>    }
> > >>
> > >> }
> > >>
> > >>
> > >> /////////////////////////////////
> > >> EchoProtocolHandler1.java
> > >>
> > >> public class EchoProtocolHandler1 extends IoHandlerAdapter {
> > >>        private static Random r=new Random();
> > >>        private static final Logger log = LoggerFactory
> > >>                        .getLogger(EchoProtocolHandler.class);
> > >>
> > >>
> > >>
> > >>        public void exceptionCaught(IoSession session, Throwable
> cause)
> > {
> > >>                cause.printStackTrace();
> > >>                session.close();
> > >>        }
> > >>
> > >>        public void messageReceived(IoSession session, Object message)
> > >>                        throws Exception {
> > >>                if (!(message instanceof ByteBuffer)) {
> > >>                        return;
> > >>                }
> > >>                Thread.currentThread().sleep(r.nextInt(1000));
> > >>
> > >>                ByteBuffer rb = (ByteBuffer) message;
> > >>                // Write the received data back to remote peer
> > >>                ByteBuffer wb = ByteBuffer.allocate(rb.remaining());
> > >>                wb.put(rb);
> > >>                wb.flip();
> > >>
> > >>
> > >>                session.write(wb);
> > >>        }
> > >>
> > >> }
> > >>
> > >> ////////////////////////////////////////////
> > >> and my client handler:
> > >>
> > >> public class ClientHandler extends IoHandlerAdapter {
> > >>
> > >>        private int num=0;
> > >>
> > >>        public ClientHandler(int num){
> > >>                this.num=num;
> > >>        }
> > >>
> > >>
> > >>        @Override
> > >>        public void sessionOpened(IoSession session) throws Exception
> {
> > >>
> > >>                for (int i = 0; i < num; i++) {
> > >>                        session.write(String.valueOf(i));
> > >>
> > >>                }
> > >>        }
> > >>        @Override
> > >>        public void messageReceived(IoSession session, Object message)
> > >>                        throws Exception {
> > >>
> > >>                System.out.println("messageReceived:"+message);
> > >>        }
> > >>
> > >>
> > >> }
> > >>
> > >>
> > >> //////////////////////////////////////////////
> > >> and ClientMain :
> > >>
> > >> public class ClientMain {
> > >>
> > >>        private static final String HOSTNAME = "localhost";
> > >>        private static final int PORT = 8080;
> > >>
> > >>        /**
> > >>         * @param args
> > >>         */
> > >>        public static void main(String[] args) {
> > >>                InetSocketAddress socketAddress = new
> > >> InetSocketAddress(HOSTNAME, PORT);
> > >>                IoServiceConfig config = new SocketConnectorConfig();
> > >>                config.setThreadModel(ThreadModel.MANUAL);
> > >>                DefaultIoFilterChainBuilder chain =
> > config.getFilterChain
> > >> ();
> > >>
> > >>        chain.addLast("threadPool", new
> > >> ExecutorFilter(Executors.newCachedThreadPool()));
> > >>
> > >>        int num=100;
> > >>
> > >>        SocketConnector connector=new SocketConnector();
> > >>
> > >>        ConnectFuture future = connector.connect(new
> InetSocketAddress(
> > >>                HOSTNAME, PORT), new ClientHandler(num), config);
> > >>
> > >>        future.join();
> > >>
> > >>
> > >>        }
> > >>
> > >> }
> > >> ///////////////////////////////////////////////////////////////
> > >> in eclipse console:
> > >>
> > >> messageReceived:0
> > >> messageReceived:1
> > >> messageReceived:2
> > >> messageReceived:3
> > >> messageReceived:4
> > >> messageReceived:5
> > >> messageReceived:6
> > >> messageReceived:7
> > >> messageReceived:8
> > >> messageReceived:9
> > >> messageReceived:10
> > >> messageReceived:11
> > >> messageReceived:12
> > >> messageReceived:13
> > >> messageReceived:14
> > >> messageReceived:15
> > >> messageReceived:16
> > >> messageReceived:17
> > >> messageReceived:18
> > >> messageReceived:19
> > >> messageReceived:20
> > >> messageReceived:21
> > >> messageReceived:22
> > >> messageReceived:23
> > >> messageReceived:24
> > >> ........
> > >> messageReceived:99
> > >>
> > >> --
> > >> View this message in context:
> > >>
> >
> http://www.nabble.com/why-client-received-message-in-order--tf4668688s16868.html#a13336726
> > >> Sent from the Apache MINA Support Forum mailing list archive at
> > >> Nabble.com
> > >> .
> > >>
> > >>
> > >
> > >
> >
> > --
> > View this message in context:
> >
> http://www.nabble.com/why-client-received-message-in-order--tf4668688s16868.html#a13338571
> > Sent from the Apache MINA Support Forum mailing list archive at
> Nabble.com
> > .
> >
> >
>

Re: why client received message in order?

Posted by mat <fo...@gmail.com>.
Try client sends more than 100. Make it 100000 and see.

On 10/22/07, tiandike <wh...@21cn.com> wrote:
>
>
> thougth my client  send some requests in one connector , the server handle
> these request in mutithread.
> if the client send request b after request a ,but the server handle b
> faster than a  and in this condition can my client receive the response b
> first?
>
>
>
> mat-29 wrote:
> >
> > I didn't see why NOT if in your client side only single thread sending
> the
> > message.
> >
> > On 10/22/07, tiandike <wh...@21cn.com> wrote:
> >>
> >>
> >> I modified the example of echoserver
> >>
> >> in my code I disable the default ThreadModel setting and configure the
> >> number of  I/O processor thread.
> >>
> >>
> >> I don't understand why my client can receive the results in order?
> >> Thanks!
> >>
> >> the code and the result is below:
> >>
> >> /////////////////////////////////
> >> the main class is :
> >> public class Main {
> >>    /** Choose your favorite port number. */
> >>    private static final int PORT = 8080;
> >>
> >>    public static void main(String[] args) throws Exception {
> >>        int num = Runtime.getRuntime().availableProcessors() * 3;
> >>        IoAcceptor acceptor = new SocketAcceptor(num,
> >> Executors.newCachedThreadPool());
> >>        IoAcceptorConfig config = new SocketAcceptorConfig();
> >>        config.setThreadModel(ThreadModel.MANUAL);
> >>        DefaultIoFilterChainBuilder chain = config.getFilterChain();
> >>        chain.addLast("threadPool", new
> >> ExecutorFilter(Executors.newCachedThreadPool()));
> >>
> >>        acceptor.bind(new InetSocketAddress(PORT), new
> >> EchoProtocolHandler1(),
> >>                config);
> >>        System.out.println("Listening on port " + PORT);
> >>    }
> >>
> >> }
> >>
> >>
> >> /////////////////////////////////
> >> EchoProtocolHandler1.java
> >>
> >> public class EchoProtocolHandler1 extends IoHandlerAdapter {
> >>        private static Random r=new Random();
> >>        private static final Logger log = LoggerFactory
> >>                        .getLogger(EchoProtocolHandler.class);
> >>
> >>
> >>
> >>        public void exceptionCaught(IoSession session, Throwable cause)
> {
> >>                cause.printStackTrace();
> >>                session.close();
> >>        }
> >>
> >>        public void messageReceived(IoSession session, Object message)
> >>                        throws Exception {
> >>                if (!(message instanceof ByteBuffer)) {
> >>                        return;
> >>                }
> >>                Thread.currentThread().sleep(r.nextInt(1000));
> >>
> >>                ByteBuffer rb = (ByteBuffer) message;
> >>                // Write the received data back to remote peer
> >>                ByteBuffer wb = ByteBuffer.allocate(rb.remaining());
> >>                wb.put(rb);
> >>                wb.flip();
> >>
> >>
> >>                session.write(wb);
> >>        }
> >>
> >> }
> >>
> >> ////////////////////////////////////////////
> >> and my client handler:
> >>
> >> public class ClientHandler extends IoHandlerAdapter {
> >>
> >>        private int num=0;
> >>
> >>        public ClientHandler(int num){
> >>                this.num=num;
> >>        }
> >>
> >>
> >>        @Override
> >>        public void sessionOpened(IoSession session) throws Exception {
> >>
> >>                for (int i = 0; i < num; i++) {
> >>                        session.write(String.valueOf(i));
> >>
> >>                }
> >>        }
> >>        @Override
> >>        public void messageReceived(IoSession session, Object message)
> >>                        throws Exception {
> >>
> >>                System.out.println("messageReceived:"+message);
> >>        }
> >>
> >>
> >> }
> >>
> >>
> >> //////////////////////////////////////////////
> >> and ClientMain :
> >>
> >> public class ClientMain {
> >>
> >>        private static final String HOSTNAME = "localhost";
> >>        private static final int PORT = 8080;
> >>
> >>        /**
> >>         * @param args
> >>         */
> >>        public static void main(String[] args) {
> >>                InetSocketAddress socketAddress = new
> >> InetSocketAddress(HOSTNAME, PORT);
> >>                IoServiceConfig config = new SocketConnectorConfig();
> >>                config.setThreadModel(ThreadModel.MANUAL);
> >>                DefaultIoFilterChainBuilder chain =
> config.getFilterChain
> >> ();
> >>
> >>        chain.addLast("threadPool", new
> >> ExecutorFilter(Executors.newCachedThreadPool()));
> >>
> >>        int num=100;
> >>
> >>        SocketConnector connector=new SocketConnector();
> >>
> >>        ConnectFuture future = connector.connect(new InetSocketAddress(
> >>                HOSTNAME, PORT), new ClientHandler(num), config);
> >>
> >>        future.join();
> >>
> >>
> >>        }
> >>
> >> }
> >> ///////////////////////////////////////////////////////////////
> >> in eclipse console:
> >>
> >> messageReceived:0
> >> messageReceived:1
> >> messageReceived:2
> >> messageReceived:3
> >> messageReceived:4
> >> messageReceived:5
> >> messageReceived:6
> >> messageReceived:7
> >> messageReceived:8
> >> messageReceived:9
> >> messageReceived:10
> >> messageReceived:11
> >> messageReceived:12
> >> messageReceived:13
> >> messageReceived:14
> >> messageReceived:15
> >> messageReceived:16
> >> messageReceived:17
> >> messageReceived:18
> >> messageReceived:19
> >> messageReceived:20
> >> messageReceived:21
> >> messageReceived:22
> >> messageReceived:23
> >> messageReceived:24
> >> ........
> >> messageReceived:99
> >>
> >> --
> >> View this message in context:
> >>
> http://www.nabble.com/why-client-received-message-in-order--tf4668688s16868.html#a13336726
> >> Sent from the Apache MINA Support Forum mailing list archive at
> >> Nabble.com
> >> .
> >>
> >>
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/why-client-received-message-in-order--tf4668688s16868.html#a13338571
> Sent from the Apache MINA Support Forum mailing list archive at Nabble.com
> .
>
>

Re: why client received message in order?

Posted by tiandike <wh...@21cn.com>.
thougth my client  send some requests in one connector , the server handle
these request in mutithread. 
if the client send request b after request a ,but the server handle b 
faster than a  and in this condition can my client receive the response b
first?



mat-29 wrote:
> 
> I didn't see why NOT if in your client side only single thread sending the
> message.
> 
> On 10/22/07, tiandike <wh...@21cn.com> wrote:
>>
>>
>> I modified the example of echoserver
>>
>> in my code I disable the default ThreadModel setting and configure the
>> number of  I/O processor thread.
>>
>>
>> I don't understand why my client can receive the results in order?
>> Thanks!
>>
>> the code and the result is below:
>>
>> /////////////////////////////////
>> the main class is :
>> public class Main {
>>    /** Choose your favorite port number. */
>>    private static final int PORT = 8080;
>>
>>    public static void main(String[] args) throws Exception {
>>        int num = Runtime.getRuntime().availableProcessors() * 3;
>>        IoAcceptor acceptor = new SocketAcceptor(num,
>> Executors.newCachedThreadPool());
>>        IoAcceptorConfig config = new SocketAcceptorConfig();
>>        config.setThreadModel(ThreadModel.MANUAL);
>>        DefaultIoFilterChainBuilder chain = config.getFilterChain();
>>        chain.addLast("threadPool", new
>> ExecutorFilter(Executors.newCachedThreadPool()));
>>
>>        acceptor.bind(new InetSocketAddress(PORT), new
>> EchoProtocolHandler1(),
>>                config);
>>        System.out.println("Listening on port " + PORT);
>>    }
>>
>> }
>>
>>
>> /////////////////////////////////
>> EchoProtocolHandler1.java
>>
>> public class EchoProtocolHandler1 extends IoHandlerAdapter {
>>        private static Random r=new Random();
>>        private static final Logger log = LoggerFactory
>>                        .getLogger(EchoProtocolHandler.class);
>>
>>
>>
>>        public void exceptionCaught(IoSession session, Throwable cause) {
>>                cause.printStackTrace();
>>                session.close();
>>        }
>>
>>        public void messageReceived(IoSession session, Object message)
>>                        throws Exception {
>>                if (!(message instanceof ByteBuffer)) {
>>                        return;
>>                }
>>                Thread.currentThread().sleep(r.nextInt(1000));
>>
>>                ByteBuffer rb = (ByteBuffer) message;
>>                // Write the received data back to remote peer
>>                ByteBuffer wb = ByteBuffer.allocate(rb.remaining());
>>                wb.put(rb);
>>                wb.flip();
>>
>>
>>                session.write(wb);
>>        }
>>
>> }
>>
>> ////////////////////////////////////////////
>> and my client handler:
>>
>> public class ClientHandler extends IoHandlerAdapter {
>>
>>        private int num=0;
>>
>>        public ClientHandler(int num){
>>                this.num=num;
>>        }
>>
>>
>>        @Override
>>        public void sessionOpened(IoSession session) throws Exception {
>>
>>                for (int i = 0; i < num; i++) {
>>                        session.write(String.valueOf(i));
>>
>>                }
>>        }
>>        @Override
>>        public void messageReceived(IoSession session, Object message)
>>                        throws Exception {
>>
>>                System.out.println("messageReceived:"+message);
>>        }
>>
>>
>> }
>>
>>
>> //////////////////////////////////////////////
>> and ClientMain :
>>
>> public class ClientMain {
>>
>>        private static final String HOSTNAME = "localhost";
>>        private static final int PORT = 8080;
>>
>>        /**
>>         * @param args
>>         */
>>        public static void main(String[] args) {
>>                InetSocketAddress socketAddress = new
>> InetSocketAddress(HOSTNAME, PORT);
>>                IoServiceConfig config = new SocketConnectorConfig();
>>                config.setThreadModel(ThreadModel.MANUAL);
>>                DefaultIoFilterChainBuilder chain = config.getFilterChain
>> ();
>>
>>        chain.addLast("threadPool", new
>> ExecutorFilter(Executors.newCachedThreadPool()));
>>
>>        int num=100;
>>
>>        SocketConnector connector=new SocketConnector();
>>
>>        ConnectFuture future = connector.connect(new InetSocketAddress(
>>                HOSTNAME, PORT), new ClientHandler(num), config);
>>
>>        future.join();
>>
>>
>>        }
>>
>> }
>> ///////////////////////////////////////////////////////////////
>> in eclipse console:
>>
>> messageReceived:0
>> messageReceived:1
>> messageReceived:2
>> messageReceived:3
>> messageReceived:4
>> messageReceived:5
>> messageReceived:6
>> messageReceived:7
>> messageReceived:8
>> messageReceived:9
>> messageReceived:10
>> messageReceived:11
>> messageReceived:12
>> messageReceived:13
>> messageReceived:14
>> messageReceived:15
>> messageReceived:16
>> messageReceived:17
>> messageReceived:18
>> messageReceived:19
>> messageReceived:20
>> messageReceived:21
>> messageReceived:22
>> messageReceived:23
>> messageReceived:24
>> ........
>> messageReceived:99
>>
>> --
>> View this message in context:
>> http://www.nabble.com/why-client-received-message-in-order--tf4668688s16868.html#a13336726
>> Sent from the Apache MINA Support Forum mailing list archive at
>> Nabble.com
>> .
>>
>>
> 
> 

-- 
View this message in context: http://www.nabble.com/why-client-received-message-in-order--tf4668688s16868.html#a13338571
Sent from the Apache MINA Support Forum mailing list archive at Nabble.com.


Re: why client received message in order?

Posted by mat <fo...@gmail.com>.
I didn't see why NOT if in your client side only single thread sending the
message.

On 10/22/07, tiandike <wh...@21cn.com> wrote:
>
>
> I modified the example of echoserver
>
> in my code I disable the default ThreadModel setting and configure the
> number of  I/O processor thread.
>
>
> I don't understand why my client can receive the results in order?
> Thanks!
>
> the code and the result is below:
>
> /////////////////////////////////
> the main class is :
> public class Main {
>    /** Choose your favorite port number. */
>    private static final int PORT = 8080;
>
>    public static void main(String[] args) throws Exception {
>        int num = Runtime.getRuntime().availableProcessors() * 3;
>        IoAcceptor acceptor = new SocketAcceptor(num,
> Executors.newCachedThreadPool());
>        IoAcceptorConfig config = new SocketAcceptorConfig();
>        config.setThreadModel(ThreadModel.MANUAL);
>        DefaultIoFilterChainBuilder chain = config.getFilterChain();
>        chain.addLast("threadPool", new
> ExecutorFilter(Executors.newCachedThreadPool()));
>
>        acceptor.bind(new InetSocketAddress(PORT), new
> EchoProtocolHandler1(),
>                config);
>        System.out.println("Listening on port " + PORT);
>    }
>
> }
>
>
> /////////////////////////////////
> EchoProtocolHandler1.java
>
> public class EchoProtocolHandler1 extends IoHandlerAdapter {
>        private static Random r=new Random();
>        private static final Logger log = LoggerFactory
>                        .getLogger(EchoProtocolHandler.class);
>
>
>
>        public void exceptionCaught(IoSession session, Throwable cause) {
>                cause.printStackTrace();
>                session.close();
>        }
>
>        public void messageReceived(IoSession session, Object message)
>                        throws Exception {
>                if (!(message instanceof ByteBuffer)) {
>                        return;
>                }
>                Thread.currentThread().sleep(r.nextInt(1000));
>
>                ByteBuffer rb = (ByteBuffer) message;
>                // Write the received data back to remote peer
>                ByteBuffer wb = ByteBuffer.allocate(rb.remaining());
>                wb.put(rb);
>                wb.flip();
>
>
>                session.write(wb);
>        }
>
> }
>
> ////////////////////////////////////////////
> and my client handler:
>
> public class ClientHandler extends IoHandlerAdapter {
>
>        private int num=0;
>
>        public ClientHandler(int num){
>                this.num=num;
>        }
>
>
>        @Override
>        public void sessionOpened(IoSession session) throws Exception {
>
>                for (int i = 0; i < num; i++) {
>                        session.write(String.valueOf(i));
>
>                }
>        }
>        @Override
>        public void messageReceived(IoSession session, Object message)
>                        throws Exception {
>
>                System.out.println("messageReceived:"+message);
>        }
>
>
> }
>
>
> //////////////////////////////////////////////
> and ClientMain :
>
> public class ClientMain {
>
>        private static final String HOSTNAME = "localhost";
>        private static final int PORT = 8080;
>
>        /**
>         * @param args
>         */
>        public static void main(String[] args) {
>                InetSocketAddress socketAddress = new
> InetSocketAddress(HOSTNAME, PORT);
>                IoServiceConfig config = new SocketConnectorConfig();
>                config.setThreadModel(ThreadModel.MANUAL);
>                DefaultIoFilterChainBuilder chain = config.getFilterChain
> ();
>
>        chain.addLast("threadPool", new
> ExecutorFilter(Executors.newCachedThreadPool()));
>
>        int num=100;
>
>        SocketConnector connector=new SocketConnector();
>
>        ConnectFuture future = connector.connect(new InetSocketAddress(
>                HOSTNAME, PORT), new ClientHandler(num), config);
>
>        future.join();
>
>
>        }
>
> }
> ///////////////////////////////////////////////////////////////
> in eclipse console:
>
> messageReceived:0
> messageReceived:1
> messageReceived:2
> messageReceived:3
> messageReceived:4
> messageReceived:5
> messageReceived:6
> messageReceived:7
> messageReceived:8
> messageReceived:9
> messageReceived:10
> messageReceived:11
> messageReceived:12
> messageReceived:13
> messageReceived:14
> messageReceived:15
> messageReceived:16
> messageReceived:17
> messageReceived:18
> messageReceived:19
> messageReceived:20
> messageReceived:21
> messageReceived:22
> messageReceived:23
> messageReceived:24
> ........
> messageReceived:99
>
> --
> View this message in context:
> http://www.nabble.com/why-client-received-message-in-order--tf4668688s16868.html#a13336726
> Sent from the Apache MINA Support Forum mailing list archive at Nabble.com
> .
>
>