Package org.apache.camel.model
Class OnCompletionDefinition
java.lang.Object
org.apache.camel.model.OptionalIdentifiedDefinition<OnCompletionDefinition>
org.apache.camel.model.ProcessorDefinition<OnCompletionDefinition>
org.apache.camel.model.OutputDefinition<OnCompletionDefinition>
org.apache.camel.model.OnCompletionDefinition
- All Implemented Interfaces:
org.apache.camel.CamelContextAware
,org.apache.camel.LineNumberAware
,Block
,ExecutorServiceAwareDefinition<OnCompletionDefinition>
,OutputNode
,org.apache.camel.NamedNode
,org.apache.camel.spi.HasCamelContext
,org.apache.camel.spi.HasId
,org.apache.camel.spi.IdAware
@Metadata(label="configuration")
public class OnCompletionDefinition
extends OutputDefinition<OnCompletionDefinition>
implements ExecutorServiceAwareDefinition<OnCompletionDefinition>
Route to be executed when normal route processing completes
-
Field Summary
Fields inherited from class org.apache.camel.model.OutputDefinition
outputs
Fields inherited from class org.apache.camel.model.ProcessorDefinition
disabled, inheritErrorHandler
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionend()
Ends the current blockexecutorService
(String executorService) Refers to a custom Thread Pool to be used for parallel processing.executorService
(ExecutorService executorService) To use a custom Thread Pool to be used for parallel processing.Gets the executor service for executingGets a reference id to lookup the executor service from the registrygetLabel()
Returns a label to describe this node such as the expression if some kind of expression nodegetMode()
boolean
Whether this model is abstract or not.boolean
boolean
Whether this definition can only be added as top-level directly on the route itself (such as onException,onCompletion,intercept, etc.)Sets the mode to be after route is done (default due backwards compatible).Sets the mode to be before consumer is done.Will only synchronize when theExchange
completed successfully (no errors).Will only synchronize when theExchange
ended with failure (exception or FAULT message).onWhen
(org.apache.camel.Predicate predicate) Sets an additional predicate that should be true before the onCompletion is triggered.If enabled then the on completion process will run asynchronously by a separate thread from a thread pool.parallelProcessing
(boolean parallelProcessing) If enabled then the on completion process will run asynchronously by a separate thread from a thread pool.void
removeAllOnCompletionDefinition
(ProcessorDefinition<?> definition) Removes all existing globalOnCompletionDefinition
from the definition.void
setExecutorService
(String executorService) void
Sets the on completion mode.void
setOnCompleteOnly
(String onCompleteOnly) void
setOnFailureOnly
(String onFailureOnly) void
setOnWhen
(WhenDefinition onWhen) void
setOutputs
(List<ProcessorDefinition<?>> outputs) void
setParallelProcessing
(String parallelProcessing) void
setParent
(ProcessorDefinition<?> parent) void
setRouteScoped
(boolean routeScoped) void
setUseOriginalMessage
(String useOriginalMessage) Will use the original input message body when anExchange
for this on completion.toString()
Deprecated.Will use the original input message when anExchange
for this on completion.Methods inherited from class org.apache.camel.model.ProcessorDefinition
addInterceptStrategy, addOutput, aggregate, aggregate, aggregate, aggregate, bean, bean, bean, bean, bean, bean, bean, bean, bean, bean, bean, choice, circuitBreaker, claimCheck, claimCheck, claimCheck, claimCheck, clearOutput, configureChild, convertBodyTo, convertBodyTo, convertBodyTo, convertHeaderTo, convertHeaderTo, convertHeaderTo, convertHeaderTo, convertVariableTo, convertVariableTo, convertVariableTo, convertVariableTo, delay, delay, delay, disabled, disabled, disabled, doTry, dynamicRouter, dynamicRouter, endChoice, endCircuitBreaker, endDoCatch, endDoTry, endParent, enrich, enrich, enrich, enrich, enrich, enrich, enrich, enrich, enrich, enrichWith, enrichWith, enrichWith, enrichWith, enrichWith, enrichWith, filter, filter, filter, filter, getDisabled, getIndex, getInterceptStrategies, getParent, getRouteConfiguration, id, idempotentConsumer, idempotentConsumer, idempotentConsumer, inheritErrorHandler, isInheritErrorHandler, isWrappingEntireOutput, kamelet, loadBalance, loadBalance, log, log, log, log, log, log, loop, loop, loop, loopDoWhile, loopDoWhile, markRollbackOnly, markRollbackOnlyLast, marshal, marshal, marshal, marshal, multicast, multicast, multicast, nodePrefixId, onCompletion, onException, onException, onException, onException, pausable, pausable, pausable, pausable, pipeline, pipeline, pipeline, policy, policy, pollEnrich, pollEnrich, pollEnrich, pollEnrich, pollEnrich, pollEnrich, pollEnrich, pollEnrich, pollEnrich, pollEnrich, pollEnrich, pollEnrich, pollEnrich, pollEnrich, pollEnrich, pollEnrich, pollEnrich, pollEnrichWith, pollEnrichWith, pollEnrichWith, pollEnrichWith, pollEnrichWith, pollEnrichWith, preCreateProcessor, process, process, process, recipientList, recipientList, recipientList, recipientList, removeHeader, removeHeaders, removeHeaders, removeProperties, removeProperties, removeProperty, removeVariable, resequence, resequence, resumable, resumable, resumable, rollback, rollback, routeDescription, routeGroup, routeId, routingSlip, routingSlip, routingSlip, saga, sample, sample, sample, sample, script, script, serviceCall, serviceCall, serviceCall, setBody, setBody, setBody, setDisabled, setExchangePattern, setExchangePattern, setHeader, setHeader, setHeader, setHeaders, setInheritErrorHandler, setProperty, setProperty, setProperty, setRouteConfiguration, setVariable, setVariable, setVariable, sort, sort, sort, split, split, split, split, startupOrder, step, step, stop, threads, threads, threads, threads, throttle, throttle, throttle, throttle, throttle, throwException, throwException, to, to, to, to, to, to, to, to, to, to, to, to, toD, toD, toD, toD, toD, toD, toD, toD, toD, toF, toV, transacted, transacted, transform, transform, transform, transform, unmarshal, unmarshal, unmarshal, unmarshal, unmarshal, unmarshal, unmarshal, validate, validate, validate, wireTap, wireTap, wireTap, wireTap, wireTap
Methods inherited from class org.apache.camel.model.OptionalIdentifiedDefinition
description, getCamelContext, getCustomId, getDescription, getDescriptionText, getId, getLineNumber, getLocation, getNodePrefixId, hasCustomIdAssigned, idOrCreate, setCamelContext, setCustomId, setDescription, setGeneratedId, setId, setLineNumber, setLocation
-
Constructor Details
-
OnCompletionDefinition
public OnCompletionDefinition()
-
-
Method Details
-
setRouteScoped
public void setRouteScoped(boolean routeScoped) -
isRouteScoped
public boolean isRouteScoped() -
setParent
- Overrides:
setParent
in classProcessorDefinition<OnCompletionDefinition>
-
toString
- Overrides:
toString
in classOutputDefinition<OnCompletionDefinition>
-
getShortName
- Specified by:
getShortName
in interfaceorg.apache.camel.NamedNode
- Overrides:
getShortName
in classOutputDefinition<OnCompletionDefinition>
-
getLabel
Description copied from class:ProcessorDefinition
Returns a label to describe this node such as the expression if some kind of expression node- Specified by:
getLabel
in interfaceorg.apache.camel.NamedNode
- Overrides:
getLabel
in classProcessorDefinition<OnCompletionDefinition>
-
isAbstract
public boolean isAbstract()Description copied from class:ProcessorDefinition
Whether this model is abstract or not. An abstract model is something that is used for configuring cross cutting concerns such as error handling, transaction policies, interceptors etc. Regular definitions is what is part of the route, such as ToDefinition, WireTapDefinition and the likes. Will by default return false to indicate regular definition, so all the abstract definitions must override this method and return true instead. This information is used in camel-spring to let Camel work a bit on the model provided by JAXB from the Spring XML file. This is needed to handle those cross cutting concerns properly. The Java DSL does not have this issue as it can work this out directly using the fluent builder methods.- Overrides:
isAbstract
in classProcessorDefinition<OnCompletionDefinition>
- Returns:
- true for abstract, otherwise false for regular.
-
isTopLevelOnly
public boolean isTopLevelOnly()Description copied from class:ProcessorDefinition
Whether this definition can only be added as top-level directly on the route itself (such as onException,onCompletion,intercept, etc.) If trying to add a top-level only definition to a nested output would fail in theProcessorDefinition.addOutput(ProcessorDefinition)
method.- Overrides:
isTopLevelOnly
in classProcessorDefinition<OnCompletionDefinition>
-
removeAllOnCompletionDefinition
Removes all existing globalOnCompletionDefinition
from the definition. This is used to let route scoped onCompletion overrule any global onCompletion. Do not remove an existing route-scoped because it is now possible (CAMEL-16374) to have several.- Parameters:
definition
- the parent definition that is the route
-
end
Description copied from class:ProcessorDefinition
Ends the current block- Overrides:
end
in classProcessorDefinition<OnCompletionDefinition>
- Returns:
- the builder
-
modeAfterConsumer
Sets the mode to be after route is done (default due backwards compatible). This executes the on completion work after the route consumer have written response back to the callee (if its InOut mode).- Returns:
- the builder
-
modeBeforeConsumer
Sets the mode to be before consumer is done. This allows the on completion work to execute before the route consumer, writes any response back to the callee (if its InOut mode).- Returns:
- the builder
-
onCompleteOnly
Will only synchronize when theExchange
completed successfully (no errors).- Returns:
- the builder
-
onFailureOnly
Will only synchronize when theExchange
ended with failure (exception or FAULT message).- Returns:
- the builder
-
onWhen
Sets an additional predicate that should be true before the onCompletion is triggered. To be used for fine grained controlling whether a completion callback should be invoked or not- Parameters:
predicate
- predicate that determines true or false- Returns:
- the builder
-
useOriginalBody
Deprecated.Will use the original input message body when anExchange
for this on completion. The original input message is defensively copied, and the copied message body is converted toStreamCache
if possible (stream caching is enabled, can be disabled globally or on the original route), to ensure the body can be read when the original message is being used later. If the body is converted toStreamCache
then the message body on the currentExchange
is replaced with theStreamCache
body. If the body is not converted toStreamCache
then the body will not be able to re-read when accessed later. Important: The original input means the input message that are bounded by the currentUnitOfWork
. An unit of work typically spans one route, or multiple routes if they are connected using internal endpoints such as direct or seda. When messages is passed via external endpoints such as JMS or HTTP then the consumer will create a new unit of work, with the message it received as input as the original input. Also some EIP patterns such as splitter, multicast, will create a new unit of work boundary for the messages in their sub-route (eg the split message); however these EIPs have an option named shareUnitOfWork which allows to combine with the parent unit of work in regard to error handling and therefore use the parent original message. By default this feature is off.- Returns:
- the builder
-
useOriginalMessage
Will use the original input message when anExchange
for this on completion. The original input message is defensively copied, and the copied message body is converted toStreamCache
if possible (stream caching is enabled, can be disabled globally or on the original route), to ensure the body can be read when the original message is being used later. If the body is converted toStreamCache
then the message body on the currentExchange
is replaced with theStreamCache
body. If the body is not converted toStreamCache
then the body will not be able to re-read when accessed later. Important: The original input means the input message that are bounded by the currentUnitOfWork
. An unit of work typically spans one route, or multiple routes if they are connected using internal endpoints such as direct or seda. When messages is passed via external endpoints such as JMS or HTTP then the consumer will create a new unit of work, with the message it received as input as the original input. Also some EIP patterns such as splitter, multicast, will create a new unit of work boundary for the messages in their sub-route (eg the split message); however these EIPs have an option named shareUnitOfWork which allows to combine with the parent unit of work in regard to error handling and therefore use the parent original message. By default this feature is off.- Returns:
- the builder
-
executorService
To use a custom Thread Pool to be used for parallel processing. Notice if you set this option, then parallel processing is automatic implied, and you do not have to enable that option as well.- Specified by:
executorService
in interfaceExecutorServiceAwareDefinition<OnCompletionDefinition>
- Parameters:
executorService
- the executor service- Returns:
- the builder
-
executorService
Refers to a custom Thread Pool to be used for parallel processing. Notice if you set this option, then parallel processing is automatic implied, and you do not have to enable that option as well.- Specified by:
executorService
in interfaceExecutorServiceAwareDefinition<OnCompletionDefinition>
- Parameters:
executorService
- reference for aExecutorService
to lookup in theRegistry
- Returns:
- the builder
-
parallelProcessing
If enabled then the on completion process will run asynchronously by a separate thread from a thread pool. By default this is false, meaning the on completion process will run synchronously using the same caller thread as from the route.- Returns:
- the builder
-
parallelProcessing
If enabled then the on completion process will run asynchronously by a separate thread from a thread pool. By default this is false, meaning the on completion process will run synchronously using the same caller thread as from the route.- Returns:
- the builder
-
getOutputs
- Overrides:
getOutputs
in classOutputDefinition<OnCompletionDefinition>
-
setOutputs
- Overrides:
setOutputs
in classOutputDefinition<OnCompletionDefinition>
-
getExecutorServiceBean
Description copied from interface:ExecutorServiceAwareDefinition
Gets the executor service for executing- Specified by:
getExecutorServiceBean
in interfaceExecutorServiceAwareDefinition<OnCompletionDefinition>
-
getExecutorServiceRef
Description copied from interface:ExecutorServiceAwareDefinition
Gets a reference id to lookup the executor service from the registry- Specified by:
getExecutorServiceRef
in interfaceExecutorServiceAwareDefinition<OnCompletionDefinition>
-
getMode
-
setMode
Sets the on completion mode. The default value is AfterConsumer -
getOnCompleteOnly
-
setOnCompleteOnly
-
getOnFailureOnly
-
setOnFailureOnly
-
getOnWhen
-
setOnWhen
-
getUseOriginalMessage
-
setUseOriginalMessage
Will use the original input message body when anExchange
for this on completion. The original input message is defensively copied, and the copied message body is converted toStreamCache
if possible (stream caching is enabled, can be disabled globally or on the original route), to ensure the body can be read when the original message is being used later. If the body is converted toStreamCache
then the message body on the currentExchange
is replaced with theStreamCache
body. If the body is not converted toStreamCache
then the body will not be able to re-read when accessed later. Important: The original input means the input message that are bounded by the currentUnitOfWork
. An unit of work typically spans one route, or multiple routes if they are connected using internal endpoints such as direct or seda. When messages is passed via external endpoints such as JMS or HTTP then the consumer will create a new unit of work, with the message it received as input as the original input. Also some EIP patterns such as splitter, multicast, will create a new unit of work boundary for the messages in their sub-route (eg the split message); however these EIPs have an option named shareUnitOfWork which allows to combine with the parent unit of work in regard to error handling and therefore use the parent original message. By default this feature is off. -
getParallelProcessing
-
setParallelProcessing
-
getExecutorService
-
setExecutorService
-
useOriginalMessage()