On Tue, Oct 7, 2008 at 9:24 PM, Ask Me <[EMAIL PROTECTED]> wrote: > I am not a network programming expert and have been assigned with the > responsibility of building a TCP/IP communication system. So I am looking > for any ideas/suggestions/guidelines etc which could help me in this. > > The requirements can be summarized as follows: > > 1. A 3rd party server will open a tcp/ip socket connection onto a port on > our network. > 2. Once they establish the connection they will send xml messages to our > server. > (I have very no control over how the 3rd party connects/handles > connections at their end) > 3. I have to read/parse/construct these xml documents and prcess them > (database lookup and/or updates) > 4. Create an XML response and send it back to the 3rd party server > 5. The maximum number concurrent xml message requests could be upto > 5000/second. > 6. The maimum size of xml documents (request and response) could be upto > 5KB. > > I am hoping to get some advice on how to approach this task. These are the > questions I have: > > 1. Does MINA be a good fit for this project?
yes > > 2. Does the 3rd party need to satisfy any special requirements in order for > me to communicate with the MINA server? no > > 3. How do I read/parse and process the xml documents? You have several options. It depends a bit on your protocol. a) Will all clients user the same character encoding for their XML messages ? b) Is there a length prefix before every message ? I have a similar server where we do not know the encoding beforehand, but every message has a length header. So we read the fixed length header (4 bytes) and then we wait until we have read that many bytes. These bytes are stored in a byte[] and then parsed by our xml parser. I find that a nice solution, our MINA code doesn't know it's dealing with XML, it just reads byte arrays. Alternatively, you could use a TextDecoder that reads until it finds the closing tag of the root tag. IMO that's a bit more complicated because you have to determine the character encoding (unless it's fixed). > 4. Any other scenarios that I should be worried about if I choose MINA? You have to make sure that you don't run out of memory when your server is too slow. Search the archive for ReadThrotlle and WriteThrotle Success, Maarten
