public class MulticastProcessor
extends org.apache.camel.support.AsyncProcessorSupport
implements org.apache.camel.Navigate<org.apache.camel.Processor>, org.apache.camel.Traceable, org.apache.camel.spi.IdAware
Pipeline
Modifier and Type | Class and Description |
---|---|
protected class |
MulticastProcessor.MulticastState |
Modifier and Type | Field and Description |
---|---|
protected org.apache.camel.Processor |
onPrepare |
Constructor and Description |
---|
MulticastProcessor(org.apache.camel.CamelContext camelContext,
Collection<org.apache.camel.Processor> processors) |
MulticastProcessor(org.apache.camel.CamelContext camelContext,
Collection<org.apache.camel.Processor> processors,
org.apache.camel.AggregationStrategy aggregationStrategy) |
MulticastProcessor(org.apache.camel.CamelContext camelContext,
Collection<org.apache.camel.Processor> processors,
org.apache.camel.AggregationStrategy aggregationStrategy,
boolean parallelProcessing,
ExecutorService executorService,
boolean shutdownExecutorService,
boolean streaming,
boolean stopOnException,
long timeout,
org.apache.camel.Processor onPrepare,
boolean shareUnitOfWork,
boolean parallelAggregate) |
MulticastProcessor(org.apache.camel.CamelContext camelContext,
Collection<org.apache.camel.Processor> processors,
org.apache.camel.AggregationStrategy aggregationStrategy,
boolean parallelProcessing,
ExecutorService executorService,
boolean shutdownExecutorService,
boolean streaming,
boolean stopOnException,
long timeout,
org.apache.camel.Processor onPrepare,
boolean shareUnitOfWork,
boolean parallelAggregate,
boolean stopOnAggregateException) |
Modifier and Type | Method and Description |
---|---|
protected void |
afterSend(ProcessorExchangePair pair,
org.apache.camel.util.StopWatch watch) |
protected org.apache.camel.util.StopWatch |
beforeSend(ProcessorExchangePair pair) |
protected ExecutorService |
createAggregateExecutorService(String name)
Strategy to create the thread pool for the aggregator background task which waits for and aggregates
completed tasks when running in parallel mode.
|
protected org.apache.camel.Processor |
createErrorHandler(org.apache.camel.spi.RouteContext routeContext,
org.apache.camel.Exchange exchange,
org.apache.camel.Processor processor) |
protected ProcessorExchangePair |
createProcessorExchangePair(int index,
org.apache.camel.Processor processor,
org.apache.camel.Exchange exchange,
org.apache.camel.spi.RouteContext routeContext)
Creates the
ProcessorExchangePair which holds the processor and exchange to be send out. |
protected Iterable<ProcessorExchangePair> |
createProcessorExchangePairs(org.apache.camel.Exchange exchange) |
protected org.apache.camel.Processor |
createUnitOfWorkProcessor(org.apache.camel.spi.RouteContext routeContext,
org.apache.camel.Processor processor,
org.apache.camel.Exchange exchange)
Strategy to create the unit of work to be used for the sub route
|
protected void |
doAggregate(AtomicReference<org.apache.camel.Exchange> result,
org.apache.camel.Exchange exchange,
org.apache.camel.Exchange inputExchange)
Aggregate the
Exchange with the current result. |
protected void |
doDone(org.apache.camel.Exchange original,
org.apache.camel.Exchange subExchange,
Iterable<ProcessorExchangePair> pairs,
org.apache.camel.AsyncCallback callback,
boolean doneSync,
boolean forceExhaust)
Common work which must be done when we are done multicasting.
|
protected void |
doShutdown() |
protected void |
doStart() |
protected void |
doStop() |
org.apache.camel.AggregationStrategy |
getAggregationStrategy()
Use
getAggregationStrategy(org.apache.camel.Exchange) instead. |
protected org.apache.camel.AggregationStrategy |
getAggregationStrategy(org.apache.camel.Exchange exchange) |
org.apache.camel.CamelContext |
getCamelContext() |
protected Integer |
getExchangeIndex(org.apache.camel.Exchange exchange) |
String |
getId() |
Collection<org.apache.camel.Processor> |
getProcessors()
Returns the producers to multicast to
|
long |
getTimeout()
An optional timeout in millis when using parallel processing
|
String |
getTraceLabel() |
boolean |
hasNext() |
boolean |
isParallelAggregate() |
boolean |
isParallelProcessing() |
boolean |
isShareUnitOfWork() |
boolean |
isStopOnAggregateException() |
boolean |
isStopOnException()
Should the multicast processor stop processing further exchanges in case of an exception occurred?
|
boolean |
isStreaming()
Is the multicast processor working in streaming mode?
In streaming mode:
we use
Iterable to ensure we can send messages as soon as the data becomes available
for parallel processing, we start aggregating responses as they get send back to the processor;
this means the AggregationStrategy has to take care of handling out-of-order arrival of exchanges
|
List<org.apache.camel.Processor> |
next() |
protected void |
prepareSharedUnitOfWork(org.apache.camel.Exchange childExchange,
org.apache.camel.Exchange parentExchange)
Prepares the exchange for participating in a shared unit of work
This ensures a child exchange can access its parent
UnitOfWork when it participate
in a shared unit of work. |
boolean |
process(org.apache.camel.Exchange exchange,
org.apache.camel.AsyncCallback callback) |
protected void |
removeAggregationStrategyFromExchange(org.apache.camel.Exchange exchange)
Removes the associated
AggregationStrategy from the Exchange
which must be done after use. |
protected void |
schedule(Executor executor,
Runnable runnable,
long delay,
TimeUnit unit) |
protected void |
schedule(Runnable runnable) |
protected void |
setAggregationStrategyOnExchange(org.apache.camel.Exchange exchange,
org.apache.camel.AggregationStrategy aggregationStrategy)
Sets the given
AggregationStrategy on the Exchange . |
void |
setId(String id) |
protected static void |
setToEndpoint(org.apache.camel.Exchange exchange,
org.apache.camel.Processor processor) |
String |
toString() |
protected void |
updateNewExchange(org.apache.camel.Exchange exchange,
int index,
Iterable<ProcessorExchangePair> allPairs,
boolean hasNext) |
doInit, doResume, doSuspend, getStatus, init, isInit, isNew, isRunAllowed, isShutdown, isStarted, isStarting, isStartingOrStarted, isStopped, isStopping, isStoppingOrStopped, isSuspended, isSuspending, isSuspendingOrSuspended, resume, shutdown, start, stop, suspend
public MulticastProcessor(org.apache.camel.CamelContext camelContext, Collection<org.apache.camel.Processor> processors)
public MulticastProcessor(org.apache.camel.CamelContext camelContext, Collection<org.apache.camel.Processor> processors, org.apache.camel.AggregationStrategy aggregationStrategy)
public MulticastProcessor(org.apache.camel.CamelContext camelContext, Collection<org.apache.camel.Processor> processors, org.apache.camel.AggregationStrategy aggregationStrategy, boolean parallelProcessing, ExecutorService executorService, boolean shutdownExecutorService, boolean streaming, boolean stopOnException, long timeout, org.apache.camel.Processor onPrepare, boolean shareUnitOfWork, boolean parallelAggregate)
public MulticastProcessor(org.apache.camel.CamelContext camelContext, Collection<org.apache.camel.Processor> processors, org.apache.camel.AggregationStrategy aggregationStrategy, boolean parallelProcessing, ExecutorService executorService, boolean shutdownExecutorService, boolean streaming, boolean stopOnException, long timeout, org.apache.camel.Processor onPrepare, boolean shareUnitOfWork, boolean parallelAggregate, boolean stopOnAggregateException)
public String getId()
getId
in interface org.apache.camel.spi.HasId
public void setId(String id)
setId
in interface org.apache.camel.spi.IdAware
public String getTraceLabel()
getTraceLabel
in interface org.apache.camel.Traceable
public org.apache.camel.CamelContext getCamelContext()
public boolean process(org.apache.camel.Exchange exchange, org.apache.camel.AsyncCallback callback)
process
in interface org.apache.camel.AsyncProcessor
protected void schedule(Runnable runnable)
protected org.apache.camel.util.StopWatch beforeSend(ProcessorExchangePair pair)
protected void afterSend(ProcessorExchangePair pair, org.apache.camel.util.StopWatch watch)
protected void doDone(org.apache.camel.Exchange original, org.apache.camel.Exchange subExchange, Iterable<ProcessorExchangePair> pairs, org.apache.camel.AsyncCallback callback, boolean doneSync, boolean forceExhaust)
original
- the original exchangesubExchange
- the current sub exchange, can be null for the synchronous partpairs
- the pairs with the exchanges to processcallback
- the callbackdoneSync
- the doneSync parameter to call on callbackforceExhaust
- whether or not error handling is exhaustedprotected void doAggregate(AtomicReference<org.apache.camel.Exchange> result, org.apache.camel.Exchange exchange, org.apache.camel.Exchange inputExchange)
Exchange
with the current result.
This method is synchronized and is called directly when parallelAggregate is disabled (by default).result
- the current resultexchange
- the exchange to be added to the resultinputExchange
- the input exchange that was sent as input to this EIPprotected void updateNewExchange(org.apache.camel.Exchange exchange, int index, Iterable<ProcessorExchangePair> allPairs, boolean hasNext)
protected Integer getExchangeIndex(org.apache.camel.Exchange exchange)
protected Iterable<ProcessorExchangePair> createProcessorExchangePairs(org.apache.camel.Exchange exchange) throws Exception
Exception
protected ProcessorExchangePair createProcessorExchangePair(int index, org.apache.camel.Processor processor, org.apache.camel.Exchange exchange, org.apache.camel.spi.RouteContext routeContext)
ProcessorExchangePair
which holds the processor and exchange to be send out.
You must use this method to create the instances of ProcessorExchangePair
as they
need to be specially prepared before use.index
- the indexprocessor
- the processorexchange
- the exchangerouteContext
- the route contextprotected org.apache.camel.Processor createErrorHandler(org.apache.camel.spi.RouteContext routeContext, org.apache.camel.Exchange exchange, org.apache.camel.Processor processor)
protected org.apache.camel.Processor createUnitOfWorkProcessor(org.apache.camel.spi.RouteContext routeContext, org.apache.camel.Processor processor, org.apache.camel.Exchange exchange)
routeContext
- the route contextprocessor
- the processorexchange
- the exchangeprotected void prepareSharedUnitOfWork(org.apache.camel.Exchange childExchange, org.apache.camel.Exchange parentExchange)
UnitOfWork
when it participate
in a shared unit of work.childExchange
- the child exchangeparentExchange
- the parent exchangeprotected void doStart() throws Exception
doStart
in class org.apache.camel.support.AsyncProcessorSupport
Exception
protected ExecutorService createAggregateExecutorService(String name)
name
- the suggested name for the background threadprotected void doStop() throws Exception
doStop
in class org.apache.camel.support.AsyncProcessorSupport
Exception
protected void doShutdown() throws Exception
doShutdown
in class org.apache.camel.support.service.ServiceSupport
Exception
protected static void setToEndpoint(org.apache.camel.Exchange exchange, org.apache.camel.Processor processor)
protected org.apache.camel.AggregationStrategy getAggregationStrategy(org.apache.camel.Exchange exchange)
protected void setAggregationStrategyOnExchange(org.apache.camel.Exchange exchange, org.apache.camel.AggregationStrategy aggregationStrategy)
AggregationStrategy
on the Exchange
.exchange
- the exchangeaggregationStrategy
- the strategyprotected void removeAggregationStrategyFromExchange(org.apache.camel.Exchange exchange)
AggregationStrategy
from the Exchange
which must be done after use.exchange
- the current exchangepublic boolean isStreaming()
Iterable
to ensure we can send messages as soon as the data becomes availableAggregationStrategy
has to take care of handling out-of-order arrival of exchangespublic boolean isStopOnException()
public Collection<org.apache.camel.Processor> getProcessors()
public long getTimeout()
public org.apache.camel.AggregationStrategy getAggregationStrategy()
getAggregationStrategy(org.apache.camel.Exchange)
instead.public boolean isParallelProcessing()
public boolean isParallelAggregate()
public boolean isStopOnAggregateException()
public boolean isShareUnitOfWork()
public List<org.apache.camel.Processor> next()
next
in interface org.apache.camel.Navigate<org.apache.camel.Processor>
public boolean hasNext()
hasNext
in interface org.apache.camel.Navigate<org.apache.camel.Processor>
Apache Camel