I use apache camel to process files received on a ftp channel. My application is deployed in a cluster (4 nodes), for this I use RedisIdempotentRepository to ensure that a single node processes the file. My problem is that I want to delete the file after processing, if I use delete=true
, the node A that processed the file when it finishes and will delete the file, node B already deleted it because the node B will not go through the filter and therefore it will directly access the deletion.
I would like to know how to only allow node A to delete the file?
from("sftp://host:port/folder?delete=true)
.idempotentConsumer(simple("${file:onlyname}"),
RedisIdempotentRepository.redisIdempotentRepository(redisTemplate, "camel-repo"))
.bean("orderTrackingFileProcessor");
I workaround this using
pollEnrich
:adding delete step at end of processing:
Full Example Route: