Results 1 to 3 of 3

Thread: Help With Aggregator

  1. #1
    Join Date
    Apr 2008
    Posts
    2

    Default Help With Aggregator

    Are there any examples of how to use the Aggregator? I am trying to create a simple test, but am new to Spring and Spring Integration and having some difficultly getting started.

    Regards

  2. #2
    Join Date
    May 2007
    Location
    Netherlands
    Posts
    614

    Default

    I hacked one into the cafe demo:
    Code:
    @MessageEndpoint(input = "preparedDrinks")
    public class OrderAggregator {
    
    	@Aggregator(defaultReplyChannel = "orderUp")
    	public DrinkOrder aggregateDrinks(Collection<Drink> drinks) {
    		DrinkOrder order = new DrinkOrder();
    		for (Drink drink : drinks) {
    			order.addDrink(drink);
    		}
    		return order;
    	}
    }
    Self explanatory I would say.

  3. #3
    Join Date
    Oct 2007
    Location
    Toronto, ON
    Posts
    90

    Default

    Hi,

    We will include documentation regarding Aggregation in the M4 release.
    Meanwhile, I would suggest to take a look at the tests. You will find some examples the com.springframework.integration.config. Look at aggregatorParserTests.xml for xml-based configuration, and to
    AggregatorAnnotationTests/CompletionStrategyAnnotationTests/TestAnnotatedEndpoint* for annotation-based configurations.

    Iwein, thanks for the sample you provided! It really shows how simple things can get. Two warnings: for once, this will work only with the latest snapshot of Spring Integration, or with the M4 distribution, due to a needed fix (INT-198). Earlier versions should return a Message and set the sequenceNumber and sequenceSize properties programmatically.
    Secondly, with the last snapshot the aggregator method now expects a List as an argument, as opposed to a collection. This is mainly to accommodate the needs of the CompletionStrategy, as well as an indicator that the collection of messages passed in has List semantics (not Set or any other kind of Collection).

    Cheers,
    Marius
    Marius Bogoevici,
    Spring Integration Committer

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •