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 Collection 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
ReactiveProcessor.ProcessingTypeflowConstruct, messagingExceptionHandler, muleContext| Constructor and Description |
|---|
ScatterGatherRouter() |
| Modifier and Type | Method and Description |
|---|---|
void |
addRoute(Processor processor)
Adds a new message processor to the list of routes
|
org.reactivestreams.Publisher<Event> |
apply(org.reactivestreams.Publisher<Event> publisher)
Applies a
Publisher function transforming a stream of Event's. |
protected List<Processor> |
getOwnedMessageProcessors() |
void |
initialise() |
Event |
process(Event event)
Invokes the MessageProcessor.
|
void |
removeRoute(Processor processor)
Removes a message processor from the list of routes
|
void |
setAggregationStrategy(AggregationStrategy aggregationStrategy) |
void |
setParallel(boolean parallel) |
void |
setRoutes(List<Processor> routes) |
void |
setTimeout(long timeout) |
void |
start() |
void |
stop() |
getOwnedObjectsdispose, getFlowConstruct, getMuleContext, setFlowConstruct, setMessagingExceptionHandler, setMuleContextgetAnnotation, getAnnotations, getLocation, setAnnotationsclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetProcessingTypesetMuleContextsetFlowConstructpublic Event process(Event event) throws org.mule.runtime.api.exception.MuleException
Processorpublic org.reactivestreams.Publisher<Event> apply(org.reactivestreams.Publisher<Event> publisher)
ProcessorPublisher function transforming a stream of Event's.
The default implementation delegates to Processor.process(Event) and will:
Processor.process(Event) returns null.public void initialise()
throws org.mule.runtime.api.lifecycle.InitialisationException
initialise in interface org.mule.runtime.api.lifecycle.Initialisableinitialise in class AbstractMuleObjectOwner<Processor>org.mule.runtime.api.lifecycle.InitialisationExceptionpublic void start()
throws org.mule.runtime.api.exception.MuleException
start in interface org.mule.runtime.api.lifecycle.Startablestart in class AbstractMuleObjectOwner<Processor>org.mule.runtime.api.exception.MuleExceptionpublic void stop()
throws org.mule.runtime.api.exception.MuleException
stop in interface org.mule.runtime.api.lifecycle.Stoppablestop in class AbstractMuleObjectOwner<Processor>org.mule.runtime.api.exception.MuleExceptionpublic void addRoute(Processor processor) throws org.mule.runtime.api.exception.MuleException
addRoute in interface MessageRouterprocessor - new destination message processorIllegalStateException - if invoked after initialise() is completedorg.mule.runtime.api.exception.MuleExceptionpublic void removeRoute(Processor processor) throws org.mule.runtime.api.exception.MuleException
removeRoute in interface MessageRouterprocessor - destination message processor to removeIllegalStateException - if invoked after initialise() is completedorg.mule.runtime.api.exception.MuleExceptionprotected List<Processor> getOwnedMessageProcessors()
getOwnedMessageProcessors in class AbstractMessageProcessorOwnerpublic void setAggregationStrategy(AggregationStrategy aggregationStrategy)
public void setParallel(boolean parallel)
public void setTimeout(long timeout)
Copyright © 2003–2017 MuleSoft, Inc.. All rights reserved.