Hi,

> The main problem is on my processors threading model. I read the doc and it
> describes that most processors should be singleton. But in my case my
> processor can not be singleton because it depends on some non-thread-safe
> complicate calculation libraries.

You can use ThreadLocal to cache the instance of your library per
thread in the processor.

private ThreadLocal<NonThreadSafeExpensiveToCreateUtil> util =
new ThreadLocal<NonThreadSafeExpensiveToCreateUtil>() {
        @Override public NonThreadSafeExpensiveToCreateUtil initialValue() {
            return new NonThreadSafeExpensiveToCreateUtil();
        }
    };

As Camel uses pool of threads, it will keep a single instance of the
util bound to each thread executing the processor.

Cheers.

-- 
Henryk Konsek
http://henryk-konsek.blogspot.com

Reply via email to