RE: [Beepcore-java-users] reading from InputDataStream ends prematurely
Status: Beta
Brought to you by:
huston
From: Wladimir A. <wa...@ju...> - 2005-12-07 14:45:31
|
I don't think using sendNul is the right thing to do. If your msg is complete, you should send a RPY. I send an empty RPY if the message I received is complete. I do this: ..... OutputDataStream os =3D new OutputDataStream(); os.setComplete(); message.sendRPY(os); ..... It doesn't matter when you send it. InputDataStream has a "copy" of the contents and they remain there until your handler returns. I don't think the RPY or NUL go out until the handler returns, so... I hope this helps.=20 Cheers, Wladimir=20 -----Original Message----- From: bee...@li... [mailto:bee...@li...] On Behalf Of Lukas Zbinden Sent: Wednesday, December 07, 2005 4:31 AM To: bee...@li... Subject: [Beepcore-java-users] reading from InputDataStream ends prematurely Hi I was wondering if someone knows the following problem and if a=20 workaround was found for it. At the recipient site of a channel connection, I read the=20 InputDataStream as follows (containing XML): public class MyRequestHandler implements RequestHandler { =09 public void receiveMSG(MessageMSG message) { InputDataStream input =3D message.getDataStream(); byte[] rawData =3D read(input); message.sendNul(); //parse XML... } public static byte[] read(InputDataStream stream) throws Exception { ByteArrayOutputStream out =3D new ByteArrayOutputStream(); do { BufferSegment b =3D stream.waitForNextSegment(); if (b =3D=3D 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=20 (channel.sendMSG(..) called at a high rate), it results in an=20 incomplete reading at the recipient site from the InputDataStream=20 delivered by the MessageMSG instance. I.e. it prematurely ends in=20 method read() and finally results in an XML parsing exception (since=20 not all data and XML, respectively, are read). Does anyone know that problem? Is it a bug in Java beepcore or am I=20 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=20 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=3D7637&alloc_id=3D16865&op=3Dclick _______________________________________________ Beepcore-java-users mailing list Bee...@li... https://lists.sourceforge.net/lists/listinfo/beepcore-java-users |