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.
<all>
implemented in the
MulticastingRouter
class, except that this router processes in parallel
instead of sequentially.
Differences with MulticastingRouter
router:
MulticastingRouter
changes to the payload performed in
route n are visible in route (n+1). When using ScatterGatherRouter
, each
route has different shallow copies of the original eventMulticastingRouter
throws
CouldNotRouteOutboundMessageException
upon route failure and stops
processing. When catching the exception, you'll have no information about the
result of any prior routes. ScatterGatherRouter
will process all routes no
matter what. It will also aggregate the results of all routes into a
MuleMessageCollection
in which each entry has the ExceptionPayload
set accordingly and then will throw a CompositeRoutingException
which will
give you visibility over the output of other routes.
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
flowConstruct, messagingExceptionHandler, muleContext
PHASE_NAME
PHASE_NAME
PHASE_NAME
PHASE_NAME
PROPERTY_NAME
Constructor and Description |
---|
ScatterGatherRouter() |
Modifier and Type | Method and Description |
---|---|
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() |
addMessageProcessorPathElements, getAnnotation, getAnnotations, getOwnedObjects, setAnnotations
getFlowConstruct, getMessagingExceptionHandler, getMuleContext, setFlowConstruct, setMessagingExceptionHandler, setMuleContext, stop
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
setMuleContext
setFlowConstruct
public MuleEvent process(MuleEvent event) throws MuleException
MessageProcessor
process
in interface MessageProcessor
event
- MuleEvent to be processedMuleException
public void initialise() throws InitialisationException
Initialisable
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.initialise
in interface Initialisable
initialise
in class AbstractMuleObjectOwner<MessageProcessor>
InitialisationException
- if a fatal error occurs causing the Mule instance to shutdownRecoverableException
- if an error occurs that can be recovered frompublic void start() throws MuleException
start
in interface Startable
start
in class AbstractMuleObjectOwner<MessageProcessor>
MuleException
public void dispose()
Disposable
dispose
in interface Disposable
dispose
in class AbstractMuleObjectOwner<MessageProcessor>
public void addRoute(MessageProcessor processor) throws MuleException
addRoute
in interface MessageRouter
processor
- new destination message processorIllegalStateException
- if invoked after initialise()
is
completedMuleException
public void removeRoute(MessageProcessor processor) throws MuleException
removeRoute
in interface MessageRouter
processor
- destination message processor to removeIllegalStateException
- if invoked after initialise()
is
completedMuleException
protected List<MessageProcessor> getOwnedMessageProcessors()
getOwnedMessageProcessors
in class AbstractMessageProcessorOwner
public void setAggregationStrategy(AggregationStrategy aggregationStrategy)
public void setThreadingProfile(ThreadingProfile threadingProfile)
public void setTimeout(long timeout)
public void setRoutes(List<MessageProcessor> routes)
Copyright © 2003–2015 MuleSoft, Inc.. All rights reserved.