I have a directory, to which files are being pushed by a camel route. From the same directory, I require multiple threads to consume the files and process them.
<route id="processMessagesFromDirectory">
<from uri="file:/directory?readLock=changed" />
<threads poolSize="8"></threads>
<doTry>
<log message="process Initiated for ${body}" />
<doCatch>
<exception>java.lang.Exception</exception>
</doCatch>
</doTry>
<log message="Processed ${body}" />
</route>
I know using 1 thread, readLock=changed will introduce a delay of atleast 1000ms. Using multiple threads, same thing was happening, a thread is waiting 1000ms picking up a file and processing, and then another thread is picking up another file and processing and so on. What exactly is happening by using readLock=changed option? How can I introduce parallelism?
I was able to process them parallely by not using readLock=markerFile option, but I don't want to process partial messages nor want to process messages more than once. How can I do that?