org.mule.routing.response
Class AbstractResponseAggregator

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

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. Response Agrregators are used to collect responses that are usually sent to replyTo endpoints set on outbound routers. When an event is sent out via an outbound router, the response router will block the response flow on an UMOComponent until the Response Router resolves a reply or times out.


Field Summary
protected  ConcurrentMap eventGroups
          A map of EventGroup objects.
protected  ConcurrentMap locks
          A map of locks used to wait for response messages for a given message id
protected  ConcurrentMap responseMessages
          The collection of messages that are ready to be returned to the callee.
 
Fields inherited from class org.mule.routing.response.AbstractResponseRouter
correlationExtractor, logger
 
Constructor Summary
AbstractResponseAggregator()
           
 
Method Summary
protected  EventGroup addEventGroup(EventGroup group)
           
protected abstract  UMOMessage aggregateEvents(EventGroup events)
           
protected  EventGroup createEventGroup(UMOEvent event, Object groupId)
           
protected  EventGroup getEventGroup(Object groupId)
           
 UMOMessage getResponse(UMOMessage message)
          This method is called by the responding callee thread and should return the aggregated response message
 void process(UMOEvent event)
          This method is invoked when an event is received via an endpoint on this Response Router.
protected  void removeEventGroup(EventGroup group)
           
protected abstract  boolean shouldAggregateEvents(EventGroup events)
           
 
Methods inherited from class org.mule.routing.response.AbstractResponseRouter
getCallResponseAggregateIdentifier, getCorrelationExtractor, getReplyAggregateIdentifier, getTimeout, isFailOnTimeout, setCorrelationExtractor, setFailOnTimeout, setPropertyExtractorAsString, setTimeout
 
Methods inherited from class org.mule.routing.AbstractRouter
getRouterStatistics, setRouterStatistics
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.mule.umo.routing.UMORouter
getRouterStatistics, setRouterStatistics
 

Field Detail

eventGroups

protected final ConcurrentMap eventGroups
A map of EventGroup objects. These represent one or more messages to be agregated, keyed by message id. There will be one response message for every EventGroup.


locks

protected final ConcurrentMap locks
A map of locks used to wait for response messages for a given message id


responseMessages

protected final ConcurrentMap responseMessages
The collection of messages that are ready to be returned to the callee. Keyed by Message ID

Constructor Detail

AbstractResponseAggregator

public AbstractResponseAggregator()
Method Detail

process

public void process(UMOEvent event)
             throws RoutingException
Description copied from interface: UMOResponseRouter
This method is invoked when an event is received via an endpoint on this Response Router. It is responsible for tieing up the event it receives with responses waiting to return back to the callee. This method will be called by a different thread to the getResponse method. The getResponse() method block the response execution until the process method signals that a match is found.

Throws:
RoutingException

createEventGroup

protected EventGroup createEventGroup(UMOEvent event,
                                      Object groupId)
See Also:
AbstractEventAggregator.createEventGroup(UMOEvent, Object)

getEventGroup

protected EventGroup getEventGroup(Object groupId)
See Also:
AbstractEventAggregator.getEventGroup(Object)

addEventGroup

protected EventGroup addEventGroup(EventGroup group)
See Also:
AbstractEventAggregator.addEventGroup(EventGroup)

removeEventGroup

protected void removeEventGroup(EventGroup group)
See Also:
AbstractEventAggregator.removeEventGroup(EventGroup)

getResponse

public UMOMessage getResponse(UMOMessage message)
                       throws RoutingException
This method is called by the responding callee thread and should return the aggregated response message

Parameters:
message -
Returns:
Throws:
RoutingException
See Also:
UMOMessage, UMOComponent

shouldAggregateEvents

protected abstract boolean shouldAggregateEvents(EventGroup events)
See Also:
AbstractEventAggregator.shouldAggregateEvents(EventGroup)

aggregateEvents

protected abstract UMOMessage aggregateEvents(EventGroup events)
                                       throws RoutingException
Throws:
RoutingException
See Also:
AbstractEventAggregator.aggregateEvents(EventGroup)


Copyright © 2003-2008 MuleSource, Inc.. All Rights Reserved.