I'm designing an instant messaging server as a personal exercise to improve my understanding and application of multi-threading and design patterns in Java. I'm still designing, there's no code yet.
My goal is to have a server that should make effective use of a multi-CPU box. I'd like the server to be distributable across multiple boxes, but wonder if that's running before I can walk.
My initial thoughts are:
ServerSocketobject that constantly accepts client
ClientConnectionManagerhas a thread pool that spawns a new
ClientProxyobject when a client socket connection is accepted, handing in the client
ClientProxyobjects represent the client app and handles sending/receiving messages across the
Is it correct that only one
ServerSocket may bind to a Port? I take it there's no way to have a pool of objects accepting Socket connections?
I have two ideas for passing messages between
ClientProxy objects. Either directly between
ClientProxy objects that are "buddies" or via a central "Exchange" object, or better yet, pool of objects.
What are the Pros/Cons of the two approaches? Does the Exchange lend itself better to a distributed app?
Would the Observer and Mediator patterns, respectively, be appropriate?