mina-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jeff MAURY <jeffma...@jeffmaury.com>
Subject Re: use mina as a tcp client performance
Date Fri, 16 May 2014 18:16:13 GMT
Hello,

can you give the code for the rest of the application because I can't see
where all those threads are created (I see only 3 connections in your
sample).

Regards
Jeff


On Thu, May 8, 2014 at 8:59 AM, pongjy123 <15811024137@163.com> wrote:

> *hello,all*
>
> * I have a problem,I have a java process(mina tcp client), need to connect
> 1000+ tcp server,my code is :*
>  connector = new NioSocketConnector();
> connector.getFilterChain().addLast("clientCodec", new
> ProtocolCodecFilter(new SplCodecFactory(true, type)));
>  connector.getSessionConfig().setReadBufferSize(MAX_READ_BUFF_SIZE);
> connector.getSessionConfig().setUseReadOperation(true);
>  connector.setHandler(new SplClientIoHandler(this.receiver,
> connectorManager));
>  int count = 3;
>  while(--count >= 0){
> if(count < 2){
> logger.warn("retry connect count:"+count+",addr:"+addr);
>  }
> ConnectFuture connFuture = connector.connect(addr);
> connFuture.awaitUninterruptibly(CONNECT_TIMEOUT);
>  session = connFuture.getSession();
> if(session == null){
> if(count == 0){
>  throw new Exception("session is null!" + addr);
> }
> }else{
>  break;
> }
> }
> connectState = ConnectState.CONNECTED;
>
> *The problem is mina created 1000+thread, So My Processor is so slow, *
> *Are there other ways to solve it? *
> *If I can just create a thread, with multiple objects to solve the
> problem? but i don't know how to do it.*
> *Thanks.*
>
>
> 来自网易手机号码邮箱了解更多 <http://shouji.163.com>
>



-- 
Jeff MAURY


"Legacy code" often differs from its suggested alternative by actually
working and scaling.
 - Bjarne Stroustrup

http://www.jeffmaury.com
http://riadiscuss.jeffmaury.com
http://www.twitter.com/jeffmaury

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message