I'm using same kind of structure using MINA. I wanted to share the data between the 2 protocol handlers easily so instead of having 2 different server running on 2 different JVMs I set up 2 acceptors in the same server. I'm not handling the threads myself, but let MINA handle it.
Thanks, Atul On Thu, Feb 12, 2009 at 10:32 AM, Ashish <[email protected]> wrote: > Did you tried this out? > > One thing I can recall from discussions is if you provide your Thread > Pool you have to manage the life cycle. > > On Thu, Feb 12, 2009 at 3:04 AM, David Rosenstrauch <[email protected]> > wrote: > > Trying to figure out how to create a server using Mina that listens on 2 > > different ports, each speaking their own protocol. Is it as simple as > > setting up 2 IoAcceptors, and binding each to their own port? i.e.,: > > > > > > protocolAcceptor1 = new NioSocketAcceptor(processor1); > > protocolAcceptor1.setReuseAddress(true); > > protocolAcceptor1.getFilterChain().addLast("logger", new > LoggingFilter()); > > protocolAcceptor1.getFilterChain().addLast("codec", new > > ProtocolCodecFilter(new TextLineCodecFactory())); > > protocolAcceptor1.setHandler(new ProtocolOneHandler()); > > protocolAcceptor1.bind(new InetSocketAddress(PROTOCOL_ONE_PORT)); > > > > protocolAcceptor2 = new NioSocketAcceptor(processor2); > > protocolAcceptor2.setReuseAddress(true); > > protocolAcceptor2.getFilterChain().addLast("logger", new > LoggingFilter()); > > protocolAcceptor2.getFilterChain().addLast("codec", new > > ProtocolCodecFilter(new TextLineCodecFactory())); > > protocolAcceptor2.setHandler(new ProtocolTwoHandler()); > > protocolAcceptor2.bind(new InetSocketAddress(PROTOCOL_TWO_PORT)); > > > > > > Also, if so, is it possible for both acceptors to share a processing > thread > > pool? i.e.: > > > > processorThreadPool = Executors.newCachedThreadPool(); > > > > protocolAcceptor1 = new NioSocketAcceptor(new > > NioProcessor(processorThreadPool)); > > > > protocolAcceptor2 = new NioSocketAcceptor(new > > NioProcessor(processorThreadPool)); > > > > Thanks, > > > > DR > > > > > > -- > thanks > ashish > > Blog: http://www.ashishpaliwal.com/blog > > My Photo Galleries: http://www.pbase.com/ashishpaliwal >
