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

Mark Hillary commented on CAMEL-5396:
-------------------------------------

I believe there is an LRUCache in camel-core. Though I don't have access to my 
pc right now to check.

On the regex side, I've had a go at writing the replacement as a single regex 
and using a stringbuffer (unfortunatetly regexs were added to the Jdk before 
stringbuilders. However it doesn't really matter these days as the compiler 
will optimise away the locks in most cases). It is quite a bit faster in my 
tests versus string.replace/all though still slower than the StringUtils 
version.

I will post the numbers and a new patch when I get home.
                
> Improve performance of DefaultJmsKeyFormatStrategy
> --------------------------------------------------
>
>                 Key: CAMEL-5396
>                 URL: https://issues.apache.org/jira/browse/CAMEL-5396
>             Project: Camel
>          Issue Type: Improvement
>          Components: camel-jms
>    Affects Versions: 2.9.2
>            Reporter: Mark Hillary
>              Labels: patch, performance
>         Attachments: CAMEL-5396.patch, default-jms-key-strat.diff
>
>
> The current default implementation uses String.replace/replaceAll to escape 
> the illegal characters in the header key. This is unfortunate because 
> replace/replaceAll are implemented in terms of regular expressions which 
> makes the escaping quite costly for something that is executed for every 
> single message. Also it's quite likely that the headers will be identical for 
> every single message that's published via JMS. 
> The attached patch makes two changes;
> * Use Commons Lang StringUtil.replaceEach which using a StringBuilder 
> internally to do the replacement. This adds a dependency on Commons Lang.
> * Cache the output of StringUtil.replaceEach in a ConcurrentHashMap. This 
> could be moved to a separate class if caching every key is a concern. Or this 
> could be changed to use an LRUCache

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to