org.mule.routing.inbound
Class AbstractEventAggregator

java.lang.Object
  extended byorg.mule.routing.inbound.SelectiveConsumer
      extended byorg.mule.routing.inbound.AbstractEventAggregator
All Implemented Interfaces:
UMOInboundRouter, UMORouter
Direct Known Subclasses:
CorrelationAggregator

public abstract class AbstractEventAggregator
extends SelectiveConsumer

AbstractEventAggregator will aggregate a set of messages into a single message.

Version:
$Revision: 3798 $
Author:
Ross Mason

Field Summary
protected  Map eventGroups
           
protected static String NO_CORRELATION_ID
           
 
Fields inherited from class org.mule.routing.inbound.SelectiveConsumer
logger
 
Constructor Summary
AbstractEventAggregator()
           
 
Method Summary
protected  EventGroup addEvent(UMOEvent event)
          Adds the event to an event group.
protected abstract  UMOMessage aggregateEvents(EventGroup events)
          This method is invoked if the shouldAggregate method is called and returns true.
 UMOEvent[] process(UMOEvent event)
          A received UMOEvent is passed to this method for processing.
protected  void removeGroup(Object id)
           
protected abstract  boolean shouldAggregate(EventGroup events)
          Determines if the event group is ready to be aggregated.
 
Methods inherited from class org.mule.routing.inbound.SelectiveConsumer
getFilter, getRouterStatistics, isMatch, isTransformFirst, setFilter, setRouterStatistics, setTransformFirst
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NO_CORRELATION_ID

protected static final String NO_CORRELATION_ID
See Also:
Constant Field Values

eventGroups

protected Map eventGroups
Constructor Detail

AbstractEventAggregator

public AbstractEventAggregator()
Method Detail

process

public UMOEvent[] process(UMOEvent event)
                   throws MessagingException
Description copied from interface: UMOInboundRouter
A received UMOEvent is passed to this method for processing. The router can control processing by either 1. passing back a null to indicate that the router has either discarded the event of the event has been stored for further processing. A reaosn for storing the event might be that other events in it's correlation group are expected to be received. 2. Pass back an array of one or more events to be processed by the component. Often 1 event is returned, i.e. in the case of event aggregation. The router may return an array of events if a set of events have been resequenced or multiple events have been generated from a single event.

Specified by:
process in interface UMOInboundRouter
Overrides:
process in class SelectiveConsumer
Throws:
MessagingException

addEvent

protected EventGroup addEvent(UMOEvent event)
Adds the event to an event group. Groups are defined by the correlationId on the message. If no correlationId is set a default group is created for all events without a correlationId. If there is no group for the current correlationId one will be created and added to the router.

Parameters:
event -
Returns:
returns either a new EventGroup with the new event added or an Existing EventGoup with the new event added

removeGroup

protected void removeGroup(Object id)

shouldAggregate

protected abstract boolean shouldAggregate(EventGroup events)
Determines if the event group is ready to be aggregated. if the group is ready to be aggregated (this is entirely up to the application. it could be determined by volume, last modified time or some oher criteria based on the last event received)

Parameters:
events -
Returns:
true if the group is ready for aggregation

aggregateEvents

protected abstract UMOMessage aggregateEvents(EventGroup events)
                                       throws AggregationException
This method is invoked if the shouldAggregate method is called and returns true. Once this method returns an aggregated message the event group is removed from the router

Parameters:
events - the event group for this request
Returns:
an aggregated message
Throws:
AggregationException - if the aggregation fails. in this scenario the whole event group is removed and passed to the exception handler for this componenet


Copyright © 2003-2006 MuleSource Inc.. All Rights Reserved.