You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@servicemix.apache.org by "Freeman Fang (JIRA)" <ji...@apache.org> on 2011/04/20 05:37:05 UTC

[jira] [Commented] (SM-2069) SourceTransformer should cache DocumentBuilder & TransformerFactory

    [ https://issues.apache.org/jira/browse/SM-2069?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13021938#comment-13021938 ] 

Freeman Fang commented on SM-2069:
----------------------------------

Hi,
Just change your patch a little bit, restore the two public method you removed with ThreadLocal cache way
+    public TransformerFactory getTransformerFactory() {
+    	return createTransformerFactory();
     }
+    	 
+    public void setTransformerFactory(TransformerFactory transformerFactory) {
+    	transformerFactoryCache.set(new WeakReference<TransformerFactory>(transformerFactory));
+    }


> SourceTransformer should cache DocumentBuilder & TransformerFactory
> -------------------------------------------------------------------
>
>                 Key: SM-2069
>                 URL: https://issues.apache.org/jira/browse/SM-2069
>             Project: ServiceMix
>          Issue Type: Improvement
>          Components: servicemix-utils
>    Affects Versions: servicemix-utils-1.5.0
>         Environment: http://svn.apache.org/repos/asf/servicemix/utils/trunk
>            Reporter: Jonathan Anstey
>            Assignee: Freeman Fang
>         Attachments: cache_docbuilder.patch, cache_docbuilder_test.patch
>
>
> I noticed that when routing between JBI endpoints in Camel like:
> {code}
> from("jbi:endpoint:serviceNamespace:serviceA:endpointA").to("jbi:endpoint:serviceNamespace:serviceB:endpointB");
> {code}
> There is a huge overhead creating new TransformerFactory and DocumentBuilder objects. After caching these on a per thread basis I was able to get a test case down from 41.583 sec to 18.224 sec.
> To test this, apply the attached patch (cache_docbuilder.patch) to the servicemix-utils trunk, and also modify the servicemix-camel component with the attached patch (cache_docbuilder_test.patch) and run the following:
> janstey@duffman:/x1/asf/servicemix/components/trunk/engines/servicemix-camel$ mvn clean test -Dtest=SendFromCamelToJbiThenRouteToAnotherJbiComponentTest
> You may need to up surefire's Xmx as well.
> If someone is going to commit this, please only commit the code in cache_docbuilder.patch

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira