I tried UseLatestAggregationStrategy and it worked.

Code:
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"), new
UseLatestAggregationStrategy())

.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);
        mockResult.expectedBodiesReceived("message two");

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

        mockResult.assertIsSatisfied();

    }

}



On 7 April 2010 15:33, Claus Ibsen <claus.ib...@gmail.com> wrote:
> Hi
>
> Can you try without groupExchanges(). To see if its the culprit of the issue.
>
>
> On Wed, Apr 7, 2010 at 12:47 PM, eugene hardbread <elukyanc...@gmail.com> 
> wrote:
>> 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
>>
>
>
>
> --
> Claus Ibsen
> Apache Camel Committer
>
> Author of Camel in Action: http://www.manning.com/ibsen/
> Open Source Integration: http://fusesource.com
> Blog: http://davsclaus.blogspot.com/
> Twitter: http://twitter.com/davsclaus
>

Reply via email to