org.mule.routing.response
Class AbstractResponseAggregator

java.lang.Object
  extended byorg.mule.routing.response.AbstractResponseRouter
      extended byorg.mule.routing.response.AbstractResponseAggregator
All Implemented Interfaces:
UMOResponseRouter, UMORouter
Direct Known Subclasses:
ResponseCorrelationAggregator

public abstract class AbstractResponseAggregator
extends AbstractResponseRouter

AbstractResponseAggregator provides a base class for implementing response aggregator routers. This provides a thread-safe implemenetation and allows developers to customise how and when events are grouped and collated.

Version:
$Revision: 1.5 $
Author:
Ross Mason

Field Summary
protected  java.util.Map eventGroups
           
protected  Log logger
          logger used by this class
protected  long timeout
           
 
Fields inherited from class org.mule.routing.response.AbstractResponseRouter
correlationExtractor
 
Constructor Summary
AbstractResponseAggregator()
           
 
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.
 UMOMessage getResponse(UMOMessage message)
           
 long getTimeout()
           
 void process(UMOEvent event)
           
protected  void removeGroup(java.lang.String id)
           
 void setTimeout(long timeout)
           
protected abstract  boolean shouldAggregate(EventGroup events)
          Determines if the event group is ready to be aggregated.
 
Methods inherited from class org.mule.routing.response.AbstractResponseRouter
getCorrelationExtractor, getRouterStatistics, setCorrelationExtractor, setRouterStatistics
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected transient Log logger
logger used by this class


timeout

protected long timeout

eventGroups

protected java.util.Map eventGroups
Constructor Detail

AbstractResponseAggregator

public AbstractResponseAggregator()
Method Detail

process

public void process(UMOEvent event)
             throws RoutingException
Throws:
RoutingException

addEvent

protected EventGroup addEvent(UMOEvent event)
                       throws RoutingException
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:
Throws:
RoutingException

removeGroup

protected void removeGroup(java.lang.String id)

getResponse

public UMOMessage getResponse(UMOMessage message)
                       throws RoutingException
Throws:
RoutingException

getTimeout

public long getTimeout()

setTimeout

public void setTimeout(long timeout)

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:

aggregateEvents

protected abstract UMOMessage aggregateEvents(EventGroup events)
                                       throws RoutingException
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:
RoutingException - if the aggregation fails. in this scenario the whole event group is removed and passed to the exception handler for this componenet


Copyright © 2003-2005 SymphonySoft Limited. All Rights Reserved.