camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From eugene hardbread <elukyanc...@gmail.com>
Subject Re: Aggregator2: completion size using expression doesn't work?
Date Wed, 07 Apr 2010 13:27:15 GMT
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.ibsen@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 <elukyanchuk@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
>

Mime
View raw message