Class 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
  • Constructor Details

    • OnCompletionDefinition

      public OnCompletionDefinition()
  • Method Details

    • setRouteScoped

      public void setRouteScoped(boolean routeScoped)
    • isRouteScoped

      public boolean isRouteScoped()
    • setParent

      public void setParent(ProcessorDefinition<?> parent)
      Overrides:
      setParent in class ProcessorDefinition<OnCompletionDefinition>
    • toString

      public String toString()
      Overrides:
      toString in class OutputDefinition<OnCompletionDefinition>
    • getShortName

      public String getShortName()
      Specified by:
      getShortName in interface org.apache.camel.NamedNode
      Overrides:
      getShortName in class OutputDefinition<OnCompletionDefinition>
    • getLabel

      public String 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 interface org.apache.camel.NamedNode
      Overrides:
      getLabel in class ProcessorDefinition<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 class ProcessorDefinition<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 the ProcessorDefinition.addOutput(ProcessorDefinition) method.

      Overrides:
      isTopLevelOnly in class ProcessorDefinition<OnCompletionDefinition>
    • removeAllOnCompletionDefinition

      public void removeAllOnCompletionDefinition(ProcessorDefinition<?> definition)
      Removes all existing global OnCompletionDefinition 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

      public ProcessorDefinition<?> end()
      Description copied from class: ProcessorDefinition
      Ends the current block
      Overrides:
      end in class ProcessorDefinition<OnCompletionDefinition>
      Returns:
      the builder
    • modeAfterConsumer

      public OnCompletionDefinition 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

      public OnCompletionDefinition 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

      public OnCompletionDefinition onCompleteOnly()
      Will only synchronize when the Exchange completed successfully (no errors).
      Returns:
      the builder
    • onFailureOnly

      public OnCompletionDefinition onFailureOnly()
      Will only synchronize when the Exchange ended with failure (exception or FAULT message).
      Returns:
      the builder
    • onWhen

      public OnCompletionDefinition onWhen(@AsPredicate org.apache.camel.Predicate predicate)
      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 public OnCompletionDefinition useOriginalBody()
      Deprecated.
      Will use the original input message body when an Exchange for this on completion.

      The original input message is defensively copied, and the copied message body is converted to StreamCache 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 to StreamCache then the message body on the current Exchange is replaced with the StreamCache body. If the body is not converted to StreamCache 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 current UnitOfWork. 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

      public OnCompletionDefinition useOriginalMessage()
      Will use the original input message when an Exchange for this on completion.

      The original input message is defensively copied, and the copied message body is converted to StreamCache 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 to StreamCache then the message body on the current Exchange is replaced with the StreamCache body. If the body is not converted to StreamCache 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 current UnitOfWork. 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

      public OnCompletionDefinition executorService(ExecutorService 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 interface ExecutorServiceAwareDefinition<OnCompletionDefinition>
      Parameters:
      executorService - the executor service
      Returns:
      the builder
    • executorService

      public OnCompletionDefinition executorService(String 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 interface ExecutorServiceAwareDefinition<OnCompletionDefinition>
      Parameters:
      executorService - reference for a ExecutorService to lookup in the Registry
      Returns:
      the builder
    • parallelProcessing

      public OnCompletionDefinition 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

      public OnCompletionDefinition parallelProcessing(boolean 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

      public List<ProcessorDefinition<?>> getOutputs()
      Overrides:
      getOutputs in class OutputDefinition<OnCompletionDefinition>
    • setOutputs

      public void setOutputs(List<ProcessorDefinition<?>> outputs)
      Overrides:
      setOutputs in class OutputDefinition<OnCompletionDefinition>
    • getExecutorServiceBean

      public ExecutorService getExecutorServiceBean()
      Description copied from interface: ExecutorServiceAwareDefinition
      Gets the executor service for executing
      Specified by:
      getExecutorServiceBean in interface ExecutorServiceAwareDefinition<OnCompletionDefinition>
    • getExecutorServiceRef

      public String getExecutorServiceRef()
      Description copied from interface: ExecutorServiceAwareDefinition
      Gets a reference id to lookup the executor service from the registry
      Specified by:
      getExecutorServiceRef in interface ExecutorServiceAwareDefinition<OnCompletionDefinition>
    • getMode

      public String getMode()
    • setMode

      public void setMode(String mode)
      Sets the on completion mode.

      The default value is AfterConsumer

    • getOnCompleteOnly

      public String getOnCompleteOnly()
    • setOnCompleteOnly

      public void setOnCompleteOnly(String onCompleteOnly)
    • getOnFailureOnly

      public String getOnFailureOnly()
    • setOnFailureOnly

      public void setOnFailureOnly(String onFailureOnly)
    • getOnWhen

      public WhenDefinition getOnWhen()
    • setOnWhen

      public void setOnWhen(WhenDefinition onWhen)
    • getUseOriginalMessage

      public String getUseOriginalMessage()
    • setUseOriginalMessage

      public void setUseOriginalMessage(String useOriginalMessage)
      Will use the original input message body when an Exchange for this on completion.

      The original input message is defensively copied, and the copied message body is converted to StreamCache 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 to StreamCache then the message body on the current Exchange is replaced with the StreamCache body. If the body is not converted to StreamCache 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 current UnitOfWork. 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

      public String getParallelProcessing()
    • setParallelProcessing

      public void setParallelProcessing(String parallelProcessing)
    • getExecutorService

      public String getExecutorService()
    • setExecutorService

      public void setExecutorService(String executorService)