You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@directory.apache.org by Barry Kaplan <gr...@memelet.com> on 2005/06/09 20:49:04 UTC

Converting from netty2 question

I'm converting the quicfixj from netty2 to mina and [think] I am nearly done. (BTW, I did not write the orignal netty2 layer for quickfixj, so I'm learning as I go.) 

But I can't figure out one thing. With netty, quickfixj would save off its netty Session instances, and on a timer would check if they have dropped their connection. If so it would invoke Session.start(). 

Is there any corresponding capability in mina? I'm using the ProtocolConnector, but it does not seem to retain the socket address after the invocation to connect. (Where netty Session did retain this information.) Am I going to have to create a little class to hold onto the socket address for reconnection?

-- 
barry kaplan
groups1@memelet.com

Re: Converting from netty2 question

Posted by Trustin Lee <tr...@gmail.com>.
Hi Barry,

2005/6/10, Barry Kaplan <gr...@memelet.com>: 
> 
> But I can't figure out one thing. With netty, quickfixj would save off its 
> netty Session instances, and on a timer would check if they have dropped 
> their connection. If so it would invoke Session.start().
> 
> Is there any corresponding capability in mina? I'm using the 
> ProtocolConnector, but it does not seem to retain the socket address after 
> the invocation to connect. (Where netty Session did retain this 
> information.) Am I going to have to create a little class to hold onto the 
> socket address for reconnection?

 You're right. I removed Session.start() method. I added IoConnector 
instead. Here is the example code:
 public void sessionClosed( ProtocolSession session ) throws Exception
{
 // Wait for five seconds before reconnecting; you'll have to perform 
reconnection in other
 // thread actually. I just slept here for brevity.
 Thread.sleep( 5000 ); 
  // Reconnect.
 connector.connect( session.getRemoteAddress(), this );
}
 Possibly you'd better to extract this code to a method like 'reconnect()' 
so that it can reusable in more than one place.
 Trustin
-- 
what we call human nature is actually human habit
--
http://gleamynode.net/