On Completion

Table of Contents

Usage
Properties

Task to be executed when normal route processing completes

Usage

The On Completion pattern defines a set of steps that are executed when normal route processing is completed. It can either be scoped local to a specific route or globally for all routes defined in the context.

[Important]Important

Locally scoped On Completion patterns take precedent over globally scoped ones. Therefore, the globally scoped pattern will not be executed when a locally scoped On Completion pattern exists.

When specifying a locally scoped On Completion pattern, the pattern directly follows the from endpoint in the route.

When specifying a globally scoped On Completion pattern, the pattern starts a new route.

Properties

Table 67, “On Completion Properties” describes the properties you can specify using the properties editor.

Table 67. On Completion Properties

NameDescription

Description

Specifies a text description for the node. This description is included in the generated XML file, but it is informational only. It is not used by Apache Camel.

Executor Service Ref

Specifies a reference for looking up the executorService to use for thread pool management.

Id

Specifies a unique identifier for the endpoint.

The tooling automatically generates an id for a node when it is created, but you can remove that id or replace it with your own. The Camel debugger requires all nodes with a breakpoint set to have a unique id.

You can use the id to refer to endpoints in your Camel XML file.

Mode

Specifies when the onCompletion task runs.

  • AfterConsumer — [Default] runs after the route consumer writes its response back to the callee.
  • BeforeConsumer — runs before the route consumer writes its response back to the callee (if the exchange pattern is InOut). This option enables the onCompletion task to modify the exchange (for example, to add special headers).

On Complete Only

Specifies whether the path will be taken only if message processing completes successfully. Cannot be enabled if On Failure Only is enabled. The default is Disabled.

On Failure Only

Specifies whether the path will be taken only if message processing fails. Cannot be enabled if On Complete Only is enabled. The default is Disabled.

On When

Sets an additional logic that should be true before the OnCompletion is triggered. It is used for fine grained controlling whether a completion callback should be invoked or not.

Parallel Processing

Specifies whether the aggregate method on the AggregationStrategy can be called concurrently.

Use Original Message Policy

Specifies whether the message that began the route is placed in the dead letter queue instead of the message that caused the exception. The default is Disabled.