sumsrv
sumsrv

Reputation: 674

Apache Camel: Route loop is lost when choice is added to the path

I am trying to implement a route with conditions and splitters.

from("{{" + feed + ".downloadSource}}")
            .routeId(feed)
            .setProperty("workDirectory",simple("{{workDirectory}}"))
            .setProperty("splitSize",simple("{{" + feed + ".splitSize}}"))
            .setProperty("feedName", simple(feed))
            .setProperty("tableName",simple("{{" + feed + ".tableName}}"))
            .setProperty("options", simple("{{" + feed + ".options}}"))
            .setProperty("dateFormat", simple("{{" + feed + ".dateFormat}}"))
            .setProperty("headerFormat", simple("{{" + feed + ".headerFormat}}"))
            .setProperty("authenticateURL", simple("{{" + feed + ".authenticateURL}}"))
            .setProperty("username", simple("{{" + feed + ".username}}"))
            .setProperty("password", simple("{{" + feed + ".password}}"))
            .loop(24)
            .split(beanExpression(new APProcessor(), "getSplitProcessor"))
            .process(APProcessor.getDownloadProcessor())
            .process(APProcessor.getNamingProcessor())
            .to("{{" + feed + ".downloadDestination}}")
                            .choice()
                .when(simple("${property.CamelSplitComplete} == true"))
                .process(APProcessor.getAggregatorProcessor())
                .process(new RSProcessor())
                .endChoice();

When This route is executed in the APProcessor method getSplitProcessor when I retrieve the CamelLoopIndex it returns 0 everytime. If I remove the choice block it executes fine. I am missing the issue. Need help.

Upvotes: 0

Views: 1149

Answers (1)

Alexander Durnev
Alexander Durnev

Reputation: 341

A loop includes all operations until the first occurense of to. As a workaround you could move all repeatable operations into a separate direct: route.

Upvotes: 1

Related Questions