The XmlMessageProtocol is an application level tcp protocol that can be used to read streaming xml documents. The only requirement is that each document include an xml declaration at the beginning of the document of the form "SHOULD begin with an XML declaration which specifies the version of XML being used" while the xml 1.1 standard contains "Definition: XML 1.1 documents MUST begin with an XML declaration which specifies the version of XML being used". The SHOULD indicates a recommendation that, if not followed, needs to be carefully checked for unintended consequences. MUST indicates a mandatory requirement for a well-formed document. Please make sure that the xml documents being streamed begin with an xml declaration when using this class.
Data are read until a new document is found or there are no more data (momentarily). For slower networks, {@link org.mule.transport.tcp.protocols.XmlMessageEOFProtocol} may be more reliable.
Also, the default character encoding for the platform is used to decode the message bytes when looking for the XML declaration. Some caution with message character encodings is warranted.
Finally, this class uses a PushbackInputStream to enable parsing of individual messages. The stream stores any pushed-back bytes into it's own internal buffer and not the original stream. Therefore, the read buffer size is intentionally limited to insure that unread characters remain on the stream so that all data may be read later.
|
|