Announcement Announcement Module
Collapse
No announcement yet.
Help With Aggregator Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    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.

    Comment


    • #3
      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

      Comment

      Working...
      X