Good idea, will try that. Thanks a lot!
δΊ 2014/2/21 17:18, Henryk Konsek ει:
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.