Hello all, I've been contemplating building a completely event driven non-blocking server using Mina. The server will have to listen to multiple ports and handle both UDP and TCP. I'd like to use a single thread for the entire application (all acceptors) because the server will not need to access any blocking resource. This will also allow me to eliminate any locking code within the server, as with a single thread there will never be any conflicts. Is this possible with Mina? What is the proper way to accomplish this?
I'd like to explore this with several different scenarios. Would these all be handled the same or are some of these scenarios possible with Mina while others are not. Here they are: 1) Listen on multiple ports, both UDP and TCP, all incoming connections will invoke the exact same processing logic and program flow. 2) Listen on multiple ports, both UDP and TCP but connections to different ports will invoke different processing logic and program flow. 3) Listen on multiple ports, both UDP and TCP. Part way through the processing of a request a query to an external server must be made. The call to this external server will be made using Mina and NIO. Is it possible for the thread to continue on with other useful work while the external request is in flight? Of course when the response arrives the processing should resume where it left off. 4) Same as above, but need to handle the situation where the external request never returns because the remote end has gone down. The server should notice no response to the external server has arrived after some timeout period and return a response on the original connection. Assume UDP to the external server so there is no notification of a terminated connection. So, something like an http proxy server where the proxy must return a response to the client but the remote http server is down, except this is done over UDP so there is no indicator that the remote server cannot be reached except that no response ever arrives. Another consideration is mult-core, multi-processor support. Obviously with one thread (the JVM of course has lots of background threads for GC etc) my server will not take full advantage of multiple cores/processors. I could abandon the single thread approach, but that of course would mean the application would require thread synchronization. Another approach I've considered is running multiple instances of the application on a box and then having a load balancer in front. I will also have multiple separate boxes running this server so there will be a load balancer in use anyway. Considering all this, would you recommend not using the single thread approach? Even if that is your ultimate recommendation, I'd like to know how to go about implementing a single threaded mina application for each of the scenarios above, if its even possible. Thanks Rob __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com
