0

Apache Camel : I have a use case to download some set of files having an Id in the file name. i used pollenrich to get the filecount using antInclude with a regex and iterated a loop to download each file.I was able to download the files for the first time but when i tried to retry with same id expecting no file count it is giving some number with is not correct.

.pollEnrich().simple("sftp location where files are to be picked?noop=true&idempotent=false&antInclude=*${property.someID}*.*").timeout(5000)
.when(body().isEqualTo(null))
.log("No Files found")
.otherwise()
.log("file count: ${property.CamelBatchSize}")
.loop(simple("${property.CamelBatchSize}")
.pollEnrich().simple("sftp location where file are to be picked?move=Processed&antInclude=*${property.someID}*.*").timeout(5000)
.to("sftp location where files need to be saved") 

1 Answers1

0

Absolutely, it will return previous file count value in camelBatchSize. I came up with same scenario, to handle that I have added exchange properties to set camel batch size as '0' before first pollEnrich.

You can do something like this before first pollEnrich,

exchange.getProperties().put('CamelBatchSize',0);
.pollEnrich().simple("sftp location where files are to be picked?noop=true&idempotent=false&antInclude=*${property.someID}*.*").timeout(5000)
.when(body().isEqualTo(null))

This might do the trick.

Lucifer
  • 784
  • 2
  • 7
  • 20