Search code examples
fileroutesapache-camel

Using dynamic fileName in camel file route


I have a problem reading different fileName from Camel file component.

from("file:/in?fileName={{property.name}}")
    .to(file:/out)

I used fileName={{property.name}} from application.yml, but I need to use it from String.

Is there any way to use it like:

String name = "blabla.xml";

from("file:/in?fileName=${name}")
    .to(file:/out)

Solution

  • Camel don't support it. String concatenation can solve your problem:

    from("file:/in?fileName="+name) 
    

    or you can set a property and then read it:

    String name="name";
    from("direct:start")
        .setProperty("name",constant(name))
        .to("file:/in?fileName=${exchangeProperty.name}");