Hi,

I'm using Apache Mina to parse continuous XML streams. I.e. a client connects to Mina and holds a connection for its entire life-cycle. During this time the client may send and receive a lot of (small) XML messages. I wonder how I should implement this is in a good way? Right now my protocol decoder is a singleton that make use of cached thread pool because each client creates a new custom made inputstream implementation that is read in a separate thread by XStream. When new data arrives to the decode method it just pushes this data to the inputstream. The inputstream itself uses a blocking queue, so the read method waits until it has data or that an "end of stream marker" has been found, e.g. until </request> has been found. I'm letting XStream (configured with XPP3) take care of marshalling the data in the XML inputstream in this other thread. So whenever XStream has found the "end of stream marker" and created a new object from the data in the inputstream it calls the ProtocolDecoderOutput.write(..) with that object. The inputstream implementation is then "reset" so that it accepts additional data. I have my worries that this may not be optimal, especially since I "create a new thread" (well I'm using the cached thread pool) for XStream for each connection in the ProtocolDecoder. So how could I improve on this? (Comments on the XML parsing technique are also welcome).

Thanks
Johan

Reply via email to