org.springframework.integration.aggregator
Class AbstractMessageAggregator

java.lang.Object
  extended by org.springframework.integration.handler.AbstractMessageHandler
      extended by org.springframework.integration.aggregator.AbstractMessageBarrierHandler<java.util.List<Message<?>>>
          extended by org.springframework.integration.aggregator.AbstractMessageAggregator
All Implemented Interfaces:
org.springframework.beans.factory.BeanFactoryAware, org.springframework.beans.factory.InitializingBean, org.springframework.core.Ordered, MessageHandler
Direct Known Subclasses:
DefaultMessageAggregator, MethodInvokingAggregator

public abstract class AbstractMessageAggregator
extends AbstractMessageBarrierHandler<java.util.List<Message<?>>>

A base class for aggregating a group of Messages into a single Message. Extends AbstractMessageBarrierHandler and waits for a complete group of Messages to arrive. Subclasses must provide the implementation of the aggregateMessages(List) method to combine the group of Messages into a single Message.

The default strategy for determining whether a group is complete is based on the 'sequenceSize' property of the header. Alternatively, a custom implementation of the CompletionStrategy may be provided.

All considerations regarding timeout and grouping by correlationId from AbstractMessageBarrierHandler apply here as well.

Author:
Mark Fisher, Marius Bogoevici

Field Summary
 
Fields inherited from class org.springframework.integration.aggregator.AbstractMessageBarrierHandler
barriers, DEFAULT_REAPER_INTERVAL, DEFAULT_SEND_TIMEOUT, DEFAULT_TIMEOUT, DEFAULT_TRACKED_CORRRELATION_ID_CAPACITY, logger, trackedCorrelationIds
 
Fields inherited from interface org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
 
Constructor Summary
AbstractMessageAggregator()
           
 
Method Summary
protected abstract  Message<?> aggregateMessages(java.util.List<Message<?>> messages)
           
protected  MessageBarrier<java.util.List<Message<?>>> createMessageBarrier(java.lang.Object correlationKey)
          Factory method for creating a MessageBarrier implementation.
protected  void processBarrier(MessageBarrier<java.util.List<Message<?>>> barrier)
          A method for processing the information in the message barrier after a message has been added or on pruning.
 void setCompletionStrategy(CompletionStrategy completionStrategy)
          Strategy to determine whether the group of messages is complete.
 
Methods inherited from class org.springframework.integration.aggregator.AbstractMessageBarrierHandler
afterPropertiesSet, canAddMessage, discardBarrier, handleMessageInternal, isRunning, removeBarrier, resolveReplyChannelFromMessage, sendReplies, sendReply, setAutoStartup, setBeanFactory, setCorrelationStrategy, setDiscardChannel, setOutputChannel, setReaperInterval, setSendPartialResultOnTimeout, setSendTimeout, setTaskScheduler, setTimeout, setTrackedCorrelationIdCapacity, start, stop
 
Methods inherited from class org.springframework.integration.handler.AbstractMessageHandler
getOrder, handleMessage, setOrder
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractMessageAggregator

public AbstractMessageAggregator()
Method Detail

setCompletionStrategy

public void setCompletionStrategy(CompletionStrategy completionStrategy)
Strategy to determine whether the group of messages is complete.


createMessageBarrier

protected MessageBarrier<java.util.List<Message<?>>> createMessageBarrier(java.lang.Object correlationKey)
Description copied from class: AbstractMessageBarrierHandler
Factory method for creating a MessageBarrier implementation.

Specified by:
createMessageBarrier in class AbstractMessageBarrierHandler<java.util.List<Message<?>>>

processBarrier

protected void processBarrier(MessageBarrier<java.util.List<Message<?>>> barrier)
Description copied from class: AbstractMessageBarrierHandler
A method for processing the information in the message barrier after a message has been added or on pruning. The decision as to whether the messages from the MessageBarrier can be released normally belongs here, although calling code may forcibly set the MessageBarrier's 'complete' flag to true before invoking the method.

Specified by:
processBarrier in class AbstractMessageBarrierHandler<java.util.List<Message<?>>>
Parameters:
barrier - the MessageBarrier to be processed

aggregateMessages

protected abstract Message<?> aggregateMessages(java.util.List<Message<?>> messages)