camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alexey-s <alex...@mail.ru>
Subject Re: Camel Splitter slowness problem
Date Mon, 28 Oct 2013 21:39:46 GMT
Use cache JAXBContext or Marshaller/Unmarshaller in local beans.
Sample:
private SoftReference<Unmarshaller> refUnmarshaller;

private Unmarshaller getUnmarshaller() throws JAXBException {
    Unmarshaller um = refUnmarshaller != null ? refUnmarshaller.get() :
null;
    if(um == null) {
        JAXBContext jaxbContext = JAXBContext.newInstance(PACKAGE_NAME,
getClass().getClassLoader());
        um = jaxbContext.createUnmarshaller();
        refUnmarshaller = new SoftReference<Unmarshaller>(um);
    }
    return um;
}

Or sample (use Google Guava):
import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;

private static LoadingCache<Class&lt;?>, JAXBContext> cache =
CacheBuilder.newBuilder()
    .expireAfterAccess(10, TimeUnit.MINUTES)
    .build(new CacheLoader<Class&lt;?>, JAXBContext>() {
        @Override
        public JAXBContext load(Class<?> key) throws Exception {
            return JAXBContext.newInstance(key);
        }
    });

JAXBContext jc = cache.get(cls);



--
View this message in context: http://camel.465427.n5.nabble.com/Camel-Splitter-slowness-problem-tp5742307p5742333.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Mime
View raw message