I do need to send an xml response back in case of any error, either in parsing or processing. Any thoughts on how to handle the scenario Marteen described? <root><msg>this is message 1</msg></root><root>CRLF <msg>this is message 2</msg></root>
Maarten Bosteels wrote: > > I think that - given the protocol - your approach is fine. > We also do the XML parsing in the message-handling thus not with a > separate > IoFilter. > The advantage is that you can test this code independent of MINA. > > Plus, we have to send an XML response when the incoming XML is invalid, > and > doing this in messageReceived > is easier than doing it in a Decoder. > > If you do your xml parsing in a Decoder, the decoder should put some > special > marker object in the ProtocolDecoderOutput when parsing fails, and > IoHandler.messageReeceived should act upon it. > > > On Mon, Oct 20, 2008 at 11:47 PM, Emmanuel Lecharny > <[EMAIL PROTECTED]>wrote: > >> newToMina wrote: >> >>> I totally agree with you that, determining the completeness of the xml >>> documents will be the trickiest part. What I have in mind right now is >>> that >>> in the TextLineDecoder once I encounter the root end tag </message>, >>> find >>> the total number of occurances of <message> & </message> tags. If both >>> are >>> one then assume it is a valid xml document and pass it for Java >>> binding. >>> Otherwise log it notify the client about the invalid message. Am I >>> missing >>> anything here? >>> >>> >> Assuming you are using a TextLineDecoder, you will get full lines, which >> makes the XML parsing much easier. A line will either contain a full >> opening >> tag or closing tag, or some value, as soon as your XML decoder can deal >> with >> lines, it should be ok. > > > > Emmanual, I am afraid this only holds when there is at least one newline > between two xml messages. > Suppose the incoming xml looks like this: > > <root><msg>this is message 1</msg></root><root>CRLF > <msg>this is message 2</msg></root> > > I agree that it's unlikely but who knows ... > > Maarten > > >> >> >> -- >> -- >> cordialement, regards, >> Emmanuel Lécharny >> www.iktek.com >> directory.apache.org >> >> >> > > -- View this message in context: http://www.nabble.com/MINA---design-guidelines-tp20077627p20089901.html Sent from the Apache MINA User Forum mailing list archive at Nabble.com.
