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, muleContextPHASE_NAMEPHASE_NAMEPHASE_NAMEPHASE_NAMEPROPERTY_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, setAnnotationsgetFlowConstruct, getMessagingExceptionHandler, getMuleContext, setFlowConstruct, setMessagingExceptionHandler, setMuleContext, stopclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitsetMuleContextsetFlowConstructpublic MuleEvent process(MuleEvent event) throws MuleException
MessageProcessorprocess in interface MessageProcessorevent - MuleEvent to be processedMuleExceptionpublic void initialise()
throws InitialisationException
InitialisableInitialisationException 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 Initialisableinitialise 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 Startablestart in class AbstractMuleObjectOwner<MessageProcessor>MuleExceptionpublic void dispose()
Disposabledispose in interface Disposabledispose in class AbstractMuleObjectOwner<MessageProcessor>public void addRoute(MessageProcessor processor) throws MuleException
addRoute in interface MessageRouterprocessor - new destination message processorIllegalStateException - if invoked after initialise() is
completedMuleExceptionpublic void removeRoute(MessageProcessor processor) throws MuleException
removeRoute in interface MessageRouterprocessor - destination message processor to removeIllegalStateException - if invoked after initialise() is
completedMuleExceptionprotected List<MessageProcessor> getOwnedMessageProcessors()
getOwnedMessageProcessors in class AbstractMessageProcessorOwnerpublic 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.