Hi All,
I have run into a performance issue.
I have a file-poller that polls for text files (size approx. 350 kB). My
FileMarshaller reads the files and
makes them into a xml-string by prepending "<tag><![CDATA[" and appending
"]]></tag>".
Then the message content is set with 'message.setContent(new
StringSource(xml-string))'
The message then is routed using camel to an 'Expression' where it is read
as 'in.getBody(Document.class)'
The getBody can take up to 20 seconds on my machine.
When I rewrite it to 'in.getBody(String.class)' and then parse the message
myself using a 'DocumentBuilder':
DocumentBuilderFactory dbFactory =
DocumentBuilderFactory.newInstance();
dbFactory.setValidating(false);
DocumentBuilder docBuilder = dbFactory.newDocumentBuilder();
InputSource messageSource = new InputSource(new
StringReader(message));
Document body = docBuilder.parse(messageSource);
it takes around only 500 ms!!
And when I rewrite the FileMarshaller to use a 'DocumentBuilder' to build
the message and set it as an DOMSource
the getBody return almost instantly.
Why does the in.getBody(Document.class) take so much more time than parsing
the message myself?
--
Hans Bogaards
TA Team bv
The Netherlands