I have the following route DSL:
from("file:" + autoLoadBaseDir + "?move=.classified")
.loop(fileTypes.length)
.choice()
.when(header("CamelFileName").contains(fileTypes[Integer.valueOf("${CamelLoopIndex}")]))
.to("file:" + classesBaseDir + "/" + fileTypes[Integer.valueOf("${CamelLoopIndex}")]);
As shown, I wish to access the CamelLoopIndex and use it as an index in an array. The expression is not evaluated, hence the route is not created. What am I doing wrong? Thanks in advance.
Documentation on this is pretty scanty, and I've not been successful getting a solution after hours of searching.
UPDATE: I've posted the same question to the Camel Users Mailing List.
You should use ${property.CamelLoopIndex}
you can use a processor or directly access the property
${exchangeProperty.CamelLoopIndex}
...
.loop(4)
.log("${exchangeProperty.CamelLoopIndex}")
.process(exchange -> {
Integer index = (Integer) exchange.getProperty(Exchange.LOOP_INDEX);
})
.end()
...
https://camel.apache.org/components/latest/eips/loop-eip.html
https://camel.apache.org/manual/latest/processor.html
Hope this helps
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With