org.mule.routing
Class ScatterGatherRouter

java.lang.Object
  extended by org.mule.processor.AbstractMuleObjectOwner<MessageProcessor>
      extended by org.mule.processor.AbstractMessageProcessorOwner
          extended by org.mule.routing.ScatterGatherRouter
All Implemented Interfaces:
AnnotatedObject, FlowConstructAware, MuleContextAware, Disposable, Initialisable, Lifecycle, Startable, Stoppable, MessageProcessor, MessageProcessorContainer, MessageRouter

public class ScatterGatherRouter
extends AbstractMessageProcessorOwner
implements MessageRouter

The Scatter-Gather router will broadcast copies of the current message to every endpoint registered with the router in parallel.

It is very similar to the <all> implemented in the MulticastingRouter class, except that this router processes in parallel instead of sequentially.

Differences with MulticastingRouter router:

For advanced use cases, a custom AggregationStrategy can be applied to customize the logic used to aggregate the route responses back into one single element or to throw exception

EIP Reference:

Since:
3.5.0

Field Summary
 
Fields inherited from class org.mule.processor.AbstractMuleObjectOwner
flowConstruct, muleContext
 
Fields inherited from interface org.mule.api.lifecycle.Initialisable
PHASE_NAME
 
Fields inherited from interface org.mule.api.lifecycle.Startable
PHASE_NAME
 
Fields inherited from interface org.mule.api.lifecycle.Stoppable
PHASE_NAME
 
Fields inherited from interface org.mule.api.lifecycle.Disposable
PHASE_NAME
 
Fields inherited from interface org.mule.api.AnnotatedObject
PROPERTY_NAME
 
Constructor Summary
ScatterGatherRouter()
           
 
Method Summary
 void addRoute(MessageProcessor processor)
          Adds a new message processor to the list of routes
 void dispose()
          A lifecycle method where implementor should free up any resources.
protected  List<MessageProcessor> getOwnedMessageProcessors()
           
 void initialise()
          Method used to perform any initialisation work.
 MuleEvent process(MuleEvent event)
          Invokes the MessageProcessor.
 void removeRoute(MessageProcessor processor)
          Removes a message processor from the list of routes
 void setAggregationStrategy(AggregationStrategy aggregationStrategy)
           
 void setRoutes(List<MessageProcessor> routes)
           
 void setThreadingProfile(ThreadingProfile threadingProfile)
           
 void setTimeout(long timeout)
           
 void start()
           
 
Methods inherited from class org.mule.processor.AbstractMessageProcessorOwner
addMessageProcessorPathElements, getAnnotation, getAnnotations, getOwnedObjects, setAnnotations
 
Methods inherited from class org.mule.processor.AbstractMuleObjectOwner
getFlowConstruct, getMuleContext, setFlowConstruct, setMuleContext, stop
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.mule.api.lifecycle.Stoppable
stop
 
Methods inherited from interface org.mule.api.context.MuleContextAware
setMuleContext
 
Methods inherited from interface org.mule.api.construct.FlowConstructAware
setFlowConstruct
 

Constructor Detail

ScatterGatherRouter

public ScatterGatherRouter()
Method Detail

process

public MuleEvent process(MuleEvent event)
                  throws MuleException
Description copied from interface: MessageProcessor
Invokes the MessageProcessor.

Specified by:
process in interface MessageProcessor
Parameters:
event - MuleEvent to be processed
Returns:
optional response MuleEvent
Throws:
MuleException

initialise

public void initialise()
                throws InitialisationException
Description copied from interface: Initialisable
Method used to perform any initialisation work. If a fatal error occurs during initialisation an InitialisationException should be thrown, causing the Mule instance to shutdown. If the error is recoverable, say by retrying to connect, a RecoverableException should be thrown. There is no guarantee that by throwing a Recoverable exception that the Mule instance will not shut down.

Specified by:
initialise in interface Initialisable
Overrides:
initialise in class AbstractMuleObjectOwner<MessageProcessor>
Throws:
InitialisationException - if a fatal error occurs causing the Mule instance to shutdown
RecoverableException - if an error occurs that can be recovered from

start

public void start()
           throws MuleException
Specified by:
start in interface Startable
Overrides:
start in class AbstractMuleObjectOwner<MessageProcessor>
Throws:
MuleException

dispose

public void dispose()
Description copied from interface: Disposable
A lifecycle method where implementor should free up any resources. If an exception is thrown it should just be logged and processing should continue. This method should not throw Runtime exceptions.

Specified by:
dispose in interface Disposable
Overrides:
dispose in class AbstractMuleObjectOwner<MessageProcessor>

addRoute

public void addRoute(MessageProcessor processor)
              throws MuleException
Adds a new message processor to the list of routes

Specified by:
addRoute in interface MessageRouter
Parameters:
processor - new destination message processor
Throws:
IllegalStateException - if invoked after initialise() is completed
MuleException

removeRoute

public void removeRoute(MessageProcessor processor)
                 throws MuleException
Removes a message processor from the list of routes

Specified by:
removeRoute in interface MessageRouter
Parameters:
processor - destination message processor to remove
Throws:
IllegalStateException - if invoked after initialise() is completed
MuleException

getOwnedMessageProcessors

protected List<MessageProcessor> getOwnedMessageProcessors()
Specified by:
getOwnedMessageProcessors in class AbstractMessageProcessorOwner

setAggregationStrategy

public void setAggregationStrategy(AggregationStrategy aggregationStrategy)

setThreadingProfile

public void setThreadingProfile(ThreadingProfile threadingProfile)

setTimeout

public void setTimeout(long timeout)

setRoutes

public void setRoutes(List<MessageProcessor> routes)


Copyright © 2003-2014 MuleSoft, Inc.. All Rights Reserved.