简体   繁体   中英

Taking input from multiple files to a camel route

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?

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();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM