Taking input from multiple files to a camel route

434 views Asked by At

I want to write a camel route which will take input from multiple file destination and process them after aggregating. is it possible to take input from multiple files for a single route?

1

There are 1 answers

0
Pasi Österman On

Yes you can use poll-enrich to call consumer-endpoints like file to enrich the message. This works for many other consumer-endpoints as well like SFTP or message queues.

If you need to read same file multiple times it can get trickier as you'll likely have to set noop=true and possibly use something like dummy idempotent repository to get around camels default behavior.

Note that calling pollEnrich seems to clear headers / create new message so use exchange properties to persist data between pollEnrich calls.

from("file:someDirectory")
    .setProperty("file1").body()
    .pollEnrich("file:otherDirectory", 3000)
    .setProperty("file2").body()
    .pollEnrich("file:yetAnotherDirectory", 3000)
    .setProperty("file3").body();