4

I have one requirement, where I need to move multiple files present in one folder to another. This should be done based on filename which should be dynamic.

As Far I have tried out pollenrich and file (antInclude) but in both case I got struck.

<route id="readFile" autoStartup="true">
    <from uri="timer://timer1?repeatCount=1"/>
    <setHeader headerName="xxx">
       <simple>1234</simple>
    </setHeader>
    <pollEnrich timeout="15000">
        <simple>file://{{baseDirectory}}?move={{destinationDirectory}}&amp;antInclude=*_${header.xxx}.txt</simple>
    </pollEnrich>
</route>

Note: Header value will be dynamic, using javascript will pull that data and set it in header. Any help on this would most welcome.

Lucifer
  • 784
  • 2
  • 7
  • 20
  • What version of Camel are you using? If you're using an older version than `2.16` you cannot use any information from the current exchange in your `pollEnrich-endpoint`. Please show us the entire route so we can get some context. – Erik Karlstrand May 14 '18 at 07:15
  • @noMad, I have edited my question, and I am using version 2.17 – Lucifer May 14 '18 at 07:40
  • I'm thinking that maybe you have a case where the `simple-language` clashes with the `file-language`. What happens if you substitute your expression with this: `*_$simple{header.xxx}.txt`? – Erik Karlstrand May 14 '18 at 10:55
  • @noMad what ever you have suggested is not working – Lucifer May 15 '18 at 07:47
  • You should elaborate your question what you really want to do since there is another question from you with the same goal that uses a file consumer. The main difference is that with `pollEnrich` you get an aggregation of the files in one message, whereas with a file consumer you get one message per file. – burki May 15 '18 at 08:21
  • thanks for your comment Burki, I achieved my requirement. I have posted my answer. – Lucifer May 15 '18 at 09:57

1 Answers1

2

Thank you for all your response,

I achieved it by using pollenrich but tweaking something in pollenrich.

  1. Got CamelBatchsize using pollenrich.
  2. Running into a loop using size.
  3. Using the above code used to move the file. I achieved it.

Thanks.

Lucifer
  • 784
  • 2
  • 7
  • 20