Hello Tristan and everyone,

Firstly I wanted to say that what you guys have here is great. About a year
ago I was looking for a NIO framework of some kind and had no luck finding
anything so I ended up writing my own. Unfortunatly, there were many
problems and fringe cases that plagued my code so I was really relieved when
I found Mina.

Basically I'm writing a server with many continuous connections open at the
same time (approx 7,000, eventually more), I need every connection to be
able to send a request and receive a response from the server within a
reasonable amount of time. My old framework would receive any requests and
queue them up. A separate process "SchedulingThread" would run and pass off
any scheduled jobs in a roundrobin fashion into a "WorkerThreads" queue
(pool of perhaps 10 "WorkerThreads"). The "WorkerThreads" would then process
the job and queue up any responses. Being a relative novice when it comes to
server design I figured this kind of model would allow me to get the most
out of my machines resources. Anyway, I'm sorta trying to mimic (to a
degree) this kind of design using MINA...

Since I haven't found an example of this kind of "multi thread" setup I'm
working off the "Configuring Thread Model" doc in the "Advanced Topic"
section. I'm also using release 1.1.4 (would you recommend switching to
2.0?)

Anyway, this is what I currently have... obviously I sorta lost at the
moment... :)

//I'm still somewhat confused regarding what the executorservice is suppose
to do?
ExecutorService executor = ...;

IoAcceptor acceptor = new
SocketAcceptor(Runtime.getRuntime().availableProcessors() + 1,
executor.newCachedThreadPool());
IoAcceptorConfig config = new SocketAcceptorConfig();

//Disabled ThreadModel as suggested in the documentation
config.setThreadModel(ThreadModel.MANUAL);

DefaultIoFilterChainBuilder chain = config.getFilterChain();
chain.addLast("codec", new ProtocolCodecFilter(new TextLineCodecFactory()));
chain.addLast("threadPool", new
ExecutorFilter(executor.newCachedThreadPool());

//WorkerHandler extends IoHandlerAdapter, should I be doing something here
(implementing runnable in the WorkerHandler?) since this is the workhorse of
the server and I'll probably want mutliple threads running an processing...
acceptor.bind(new InetSocketAddress(PORT), new WorkerHandler(), config);

//How would I unbind?
acceptor.unbind(...);
executor.shutdown();

If anyone could point me in the right direction or better yet show me an
example I would really appreciate it... thanks ahead of time... and you guys
have something really cool here... 
-- 
View this message in context: 
http://www.nabble.com/Question-regarding-threading-tf4827942s16868.html#a13812955
Sent from the Apache MINA Support Forum mailing list archive at Nabble.com.

Reply via email to