camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From eugene hardbread <elukyanc...@gmail.com>
Subject Aggregator2: completion size using expression doesn't work?
Date Wed, 07 Apr 2010 10:47:04 GMT
Hello

I am trying to configure aggregator2 using completionSize with header
expression:

public class AggregatorTest extends CamelTestSupport{
    @EndpointInject(uri = "mock:result")
    private MockEndpoint mockResult;

    @Override
    protected RouteBuilder createRouteBuilder() throws Exception {
        return new RouteBuilder() {
            @Override
            public void configure() throws Exception {
                from("direct:aggregatorTest")

.aggregate(header("group_id")).groupExchanges().completionSize(header("quantity_in_group"))
                     .to("mock:result");

            }
        };
    }

    @Produce
    private ProducerTemplate template;

    @Test
    public void testAggregator() throws InterruptedException {
        Map<String, Object> headers = new HashMap<String, Object>();
        headers.put("group_id", 1);
        headers.put("quantity_in_group", 2);

        mockResult.setExpectedMessageCount(1);

        template.sendBodyAndHeaders("direct:aggregatorTest", "message
one", headers);
        template.sendBodyAndHeaders("direct:aggregatorTest", "message
two", headers);

        mockResult.assertIsSatisfied();

        Exchange result = mockResult.getExchanges().get(0);

        List<Exchange> group = (List<Exchange>)
result.getProperty(Exchange.GROUPED_EXCHANGE);

        assertListSize(group, 2);

    }

}

Nothing is sent to mockResult.

Am I doing something wrong or is it an aggregator2 issue? With
completionTimeout everything works fine. Version of Camel: current
2.3-SNAPSHOT from the Apache snapshot repo.

Thanks,
Eugene

Mime
View raw message