Hi,

Simple test case. Please tell me why splitting and
aggregating doesn't work I would expect it would ?
Maybe my understanding of split/aggregate is wrong ?
DSL route:

    from("direct:start")
    .splitter(body().tokenize(","), false)
    .aggregator(header("type"), joinBodyWithColon).batchTimeout(500)
    .to("mock:stop");

where joinBodyWithColon aggregation strategy just joins
messsages bodies with colon separator:

    private final AggregationStrategy joinBodyWithColon = new 
AggregationStrategy() {
        public Exchange aggregate(Exchange oldExchange, Exchange newExchange) {
            oldExchange.getIn().setBody(
                oldExchange.getIn().getBody(String.class)+
                ":"+
                newExchange.getIn().getBody(String.class));
            return oldExchange;
        }
    };

    
after sending

    template.sendBodyAndHeader(
        "direct:start", ExchangePattern.InOnly,
        "red,green,blue",
        "type", "sometype");

endpoint "mock:stop" receives 1 message with body "red,green,blue"
while in my opinion it should receive 1 message with body "red:gree:blue".

BTW. When I insert direct endpoint between split end aggregate
elements - it works as expected.
Below route passes "red:green:blue" to mock endpoint:

    from("direct:start")
    .splitter(body().tokenize(","), false)
    .to("direct:foo");

    from("direct:foo")
    .aggregator(header("type"), joinBodyWithColon).batchTimeout(500)
    .to("mock:stop");

Thanks in advance
Tomek




Reply via email to