Class DynamicRouterProcessor
java.lang.Object
org.apache.camel.support.service.BaseService
org.apache.camel.support.service.ServiceSupport
org.apache.camel.support.AsyncProcessorSupport
org.apache.camel.component.dynamicrouter.routing.DynamicRouterProcessor
- All Implemented Interfaces:
AutoCloseable
,org.apache.camel.AsyncProcessor
,org.apache.camel.Processor
,org.apache.camel.Service
,org.apache.camel.ShutdownableService
,org.apache.camel.StatefulService
,org.apache.camel.SuspendableService
public class DynamicRouterProcessor
extends org.apache.camel.support.AsyncProcessorSupport
The
DynamicRouterProcessor
is responsible for routing an exchange to the appropriate recipients. It uses the
DynamicRouterFilterService
to determine which filters match the exchange, and then sets the recipient list
header on the exchange to the list of matching filters. The RecipientList
processor is then used to route the
exchange to the matching recipients.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
Factory for creatingDynamicRouterProcessor
instances. -
Field Summary
Fields inherited from class org.apache.camel.support.service.BaseService
BUILT, FAILED, INITIALIZED, INITIALIZING, lock, NEW, SHUTDOWN, SHUTTING_DOWN, STARTED, STARTING, status, STOPPED, STOPPING, SUSPENDED, SUSPENDING
-
Constructor Summary
ConstructorsConstructorDescriptionDynamicRouterProcessor
(String recipientMode, boolean warnDroppedMessage, String channel, org.apache.camel.processor.RecipientList recipientList, DynamicRouterFilterService filterService) Construct theDynamicRouterProcessor
instance. -
Method Summary
Modifier and TypeMethodDescriptionprotected String
matchFilters
(org.apache.camel.Exchange exchange) Match the exchange against all filters to determine if any of them are suitable to handle the exchange.void
prepareExchange
(org.apache.camel.Exchange exchange) Prepare the exchange for processing by matching the exchange against the filters, and setting the recipient list based on matching filter URIs.void
process
(org.apache.camel.Exchange exchange) Process the exchange asynchronously.boolean
process
(org.apache.camel.Exchange exchange, org.apache.camel.AsyncCallback callback) Process the exchange, and use theAsyncCallback
to signal completion.Methods inherited from class org.apache.camel.support.AsyncProcessorSupport
processAsync
Methods inherited from class org.apache.camel.support.service.BaseService
build, doBuild, doFail, doInit, doLifecycleChange, doResume, doShutdown, doStart, doStop, doSuspend, fail, getInternalLock, getStatus, init, isBuild, isInit, isNew, isRunAllowed, isShutdown, isStarted, isStarting, isStartingOrStarted, isStopped, isStopping, isStoppingOrStopped, isSuspended, isSuspending, isSuspendingOrSuspended, resume, shutdown, start, stop, suspend
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.apache.camel.Service
build, close, init, start, stop
Methods inherited from interface org.apache.camel.ShutdownableService
shutdown
Methods inherited from interface org.apache.camel.StatefulService
getStatus, isRunAllowed, isStarted, isStarting, isStopped, isStopping, isSuspending
Methods inherited from interface org.apache.camel.SuspendableService
isSuspended, resume, suspend
-
Constructor Details
-
DynamicRouterProcessor
public DynamicRouterProcessor(String recipientMode, boolean warnDroppedMessage, String channel, org.apache.camel.processor.RecipientList recipientList, DynamicRouterFilterService filterService) Construct theDynamicRouterProcessor
instance.- Parameters:
recipientMode
- the recipient modewarnDroppedMessage
- flag from the configuration to indicate if a dropped message should be logged at the 'WARN' levelchannel
- the channel of the Dynamic Router that this processor servicesrecipientList
- the recipient list processorfilterService
- service that managesPrioritizedFilter
s for dynamic router channels
-
-
Method Details
-
matchFilters
Match the exchange against all filters to determine if any of them are suitable to handle the exchange.- Parameters:
exchange
- the message exchange- Returns:
- list of filters that match for the exchange; if "firstMatch" mode, it is a singleton list of that filter
-
prepareExchange
public void prepareExchange(org.apache.camel.Exchange exchange) Prepare the exchange for processing by matching the exchange against the filters, and setting the recipient list based on matching filter URIs.- Parameters:
exchange
- the message exchange
-
process
Process the exchange asynchronously. The underlying RecipientList will handle the processing, including a check to see if the exchange should be processed synchronously or asynchronously.- Specified by:
process
in interfaceorg.apache.camel.Processor
- Overrides:
process
in classorg.apache.camel.support.AsyncProcessorSupport
- Parameters:
exchange
- the exchange to process- Throws:
Exception
-
process
public boolean process(org.apache.camel.Exchange exchange, org.apache.camel.AsyncCallback callback) Process the exchange, and use theAsyncCallback
to signal completion.- Parameters:
exchange
- the exchange to processcallback
- theAsyncCallback
to signal when asynchronous processing has completed- Returns:
- true to continue to execute synchronously, or false to continue to execute asynchronously
-