Thanks Christian, I managed to sort out this issue. I'm not sure this is an
optimal way of achieving my objective, but it works.

Having experimented around with a number of options, the following works
for me:

    from("file:" + autoLoadBaseDir + "?preMove=inprogress&move=.classified")
    .routeId("Test-Route")
    .loop(fileTypes.length)
    .processRef("keFileTypeNameService")
    .choice()
    .when(header("CamelFileName").contains(header("MyFileType")))
    .to("file:" + classesBaseDir +
"/?autoCreate=true&fileName=${header[MyFileType]}/${header[CamelFileName]}");

The `keFileTypeNameService` retrieves the `CamelLoopIndex` property from
the exchange. It then uses this to get the file type at that index. It then
just simply set this file type name in the header. The
`keFileTypeNameService` bean is shown below:

    @Service( value = "keFileTypeNameService" )
    public class FileTypeNameService implements Processor {

    private @Value("${ke.file.types}") String[] fileTypes;

    public void process(Exchange exchange) throws Exception {
    Integer count = exchange.getProperty("CamelLoopIndex", Integer.class);
    String fileType = fileTypes[count];
    exchange.getIn().setHeader("MyFileType", fileType);
    }




    }

I hope this assists someone else.


On Thu, Apr 11, 2013 at 11:18 PM, Christian Mueller <
christian.muel...@gmail.com> wrote:

> Try:
> .when(simple("${header[CamelFileName]} contains
> ${header[CamelLoopIndex]}"))
>
> You can find more about the simple language at [1].
>
> [1] http://camel.apache.org/simple.html
>
> Best,
> Christian
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/Accessing-CamelLoopIndex-in-route-tp5730719p5730731.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>



-- 
Kind Regards,
Okello Nelson
+254 722 137 826
cn.oke...@gmail.com

Reply via email to