How to set value for antInclude attribute from exchange property in apache camel

前端 未结 1 701
Happy的楠姐
Happy的楠姐 2021-01-26 10:35

I am adding a property to exchange at runtime from the request.

exchange.setProperty(\"filePattern\", String.format(\"*%s*\", routeConfig.getFilePattern()))
         


        
1条回答
  •  时光取名叫无心
    2021-01-26 11:39

    Aha! I see what you are trying to do here. Simple expressions won't work that way with a Polling Consumer like File2.

    If you are using Camel 2.16+, you can use pollEnrich to get a behavior that you are trying to get here. It would be something like

    from("direct:inputFileRoute")
                    .pollEnrich("file:src/data?noop=true&antInclude=${exchange.filePattern}")
                    .log("File Pattern is: ${exchangeProperty.filePattern}");
    

    On a sidenote, are you sure you have to tweak the antiInclude option on the File component for every exchange? It looks like an overkill but I am unable to make a judgement based on the very limited input available here. Perhaps what you are looking for is Camel Properties

    0 讨论(0)
提交回复
热议问题