reading from InputDataStream ends prematurely

"Lukas Zbinden" <[email protected]> Wed, 7 Dec 2005 10:31:17 +0100
Newsgroups gmane.network.beep.beepcore.java.general
Message-ID <[email protected]>
Hi

I was wondering if someone knows the following problem and if a 
workaround was found for it.

At the recipient site of a channel connection, I read the 
InputDataStream as follows (containing XML):


public class MyRequestHandler implements RequestHandler {
	

	public void receiveMSG(MessageMSG message) {

			InputDataStream input = message.getDataStream();
			byte[] rawData = read(input);

			message.sendNul();

			//parse XML...

	}

	public static byte[] read(InputDataStream stream) throws Exception {
		ByteArrayOutputStream out = new ByteArrayOutputStream();
		do {
             		BufferSegment b = stream.waitForNextSegment();
             		 if (b == null) {
	         	 		   continue;
              		}
              		out.write(b.getData());
         		} while (!stream.isComplete());
		out.flush();
		return out.toByteArray();
	}
}



When the sender site sends many messages in a short time 
(channel.sendMSG(..) called at a high rate), it results in an 
incomplete reading at the recipient site from the InputDataStream 
delivered by the MessageMSG instance. I.e. it prematurely ends in 
method read() and finally results in an XML parsing exception (since 
not all data and XML, respectively, are read).

Does anyone know that problem? Is it a bug in Java beepcore or am I 
reading the InputDataStream the wrong way?
I do have ensured that only one thread executes receiveMSG() at a time.

Another interesting issue: Does it matter if sendNul() is called before 
or after reading the InputDataStream?


Thanks for any thoughts...
-- Lukas



-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click