apache-camelcontinuesplitter

Apache camel continue in splitter


I'm pretty new in camel, sorry if this question is stupid but lets say I have a camel splitter which iterates over some objects from the database. I'd like to ask if there is something like continue in camel splitter. Let's say I have an array of numbers like {1,2,3,4} in a body and I want to print numbers, but I don't want to print number 3. I know I can use choose but in some cases continue would be a better option. Thank you very much.


Solution

  • In this case, I would use Message Filter EIP, either with filter(Predicate) or stop()

    Using filter:

    from("direct:filter3")
        .split(body())
        .filter(body().isNotEqualTo(3))
        .to("log:splitted");
    

    Using stop:

    from("direct:stop3")
        .split(body())
        .choice().when(body().isEqualTo(3)).stop().end()
        .to("log:splitted");