You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@servicemix.apache.org by Hans Bogaards <ha...@tateam.nl> on 2008/10/23 11:57:01 UTC

Performance issue StringSource message content and reading it as DOM document

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

Re: Performance issue StringSource message content and reading it as DOM document

Posted by Hans Bogaards <hb...@gmail.com>.
>
> Hi Gert & All,
>
> You'd expect a very limited amount of overhead in looking up the correct
>> @Convertor in Camel, but that should take that long!  Do you think you can
>> provide us with a unit test or a test SA and attach that to a JIRA issue, so
>> we can look into this?
>
>
> I'll try to create a test SA that exhibits this.
>

I have tried to recreate it, but have not yet been able to. Will try further
tomorrow.
--
Hans

Re: Performance issue StringSource message content and reading it as DOM document

Posted by Hans Bogaards <hb...@gmail.com>.
Hi Gert & All,

You'd expect a very limited amount of overhead in looking up the correct
> @Convertor in Camel, but that should take that long!  Do you think you can
> provide us with a unit test or a test SA and attach that to a JIRA issue, so
> we can look into this?


I'll try to create a test SA that exhibits this.
--
Hans

Re: Performance issue StringSource message content and reading it as DOM document

Posted by Gert Vanthienen <ge...@skynet.be>.
Hans,

You'd expect a very limited amount of overhead in looking up the correct 
@Convertor in Camel, but that should take that long!  Do you think you 
can provide us with a unit test or a test SA and attach that to a JIRA 
issue, so we can look into this?

Regards,

Gert

Hans Bogaards wrote:
> 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?
>
>