I have a file: route camel component, which uses an aggregationStrategy with completionFromBatchConsumer as the stop condition.
My aggregator implements CompletionAwareAggregationStrategy
The route itself works fine.
I’m currently trying to define a readLock=changed strategy to skip files which are being written by another process, which works fine too.
The problem is, when a file gets skipped due to readLock, it seems that the batch size is not updated, and hence the onCompletion method of the aggregator is never called resulting in an dead route.
Shouldn’t camel check the readLock before calculating the size of the batch? is there any way to achieve this or any equivalent solution?
TKS
Ah you have hit a caveat. The read lock is applied on the fly, and not eagerly. So the batch consumer may see there is 10 files, but the read-lock can only be applied for 9 files currently. And if you have a read lock timeout, then the file is skipped. If you dont have timeout, then the read-lock will eventually be granted and all 10 files can be processed.
I am not sure if there is something easy that can be done, as the completion details could be updated accordingly, but the very last file could be the read-lock problem. And then you won’t have a trigger.
We could possible add a feature to emit an empty exchange on read-lock not granted. And then you would need to be aware of this, and deal with this in your custom aggregation strategy.