On Exception

Table of Contents

Usage
Properties
Related topics

Route to be executed when an exception is thrown

Usage

The On Exception pattern defines a set of steps that are executed when an exception is thrown. It can be scoped either locally to a specific route or globally to all routes defined in the context.

[Important]Important

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

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

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

Properties

Table 68, “On Exception Properties” describes the properties you can specify using the properties editor.

Table 68. On Exception Properties

NameDescription

Exception

Specifies the list of exceptions the node handles. The Add button adds an entry typed in the field. The Delete button removes the selected entry from the list.

Language

Specifies the expression language used to process the continued expression.

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.

Language

Specifies the expression language used to process the expression.

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.

On Exception Occurred Ref

Specifies a reference to a processor that should be processed just after an exception occured.

On Redelivery Ref

Specifies a reference to a custom processor for processing the message before it is redelivered.

On When

Sets an additional logic that should be true before the OnException is triggered. It is used for fine grained controlling whether a thrown exception should be intercepted by this exception type or not.

Redelivery Policy

Specifies how to handle failed deliveries. Redelivery options are listed in Table 69, “Redelivery Properties”.

Redelivery Policy Ref

Specifies a reference to bean defining the redelivery policy.

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.


Redelivery Policy Table 69, “Redelivery Properties” describes the properties for configuring the redelivery policy.

Table 69. Redelivery Properties

NameDescription

Allow Redelivery While Stopping

Specifies whether to allow redelivery while a route that uses error handling shuts down.

When enabled, the route attempts redelivery of inflight messages during shutdown.

When disabled, no attempts to redeliver are made, resulting in the failure of inflight messages and the cessation of message processing.

The default is Disabled.

Async Delayed Redelivery

Specifies whether asynchronous delayed redelivery is used to scheduled redelivers at a later time. When enabled, an asynchronous thread, rather than the current thread, performs redelivery. This ensures that no thread is blocked waiting for a redelivery. The default is Disabled.

Back Off Multiplier

Specifies the multiplier used to determine the redelivery delay if exponential back-off is enabled. If m is the back-off multiplier and d is the redelivery delay, the sequence of redelivery attempts are then timed as follows:

d, m*d, m*m*d, m*m*m*d, ...

The default is 2.

Collision Avoidance Factor

Specifies a factor that is used to randomly tweak the redelivery delay if collision avoidance is enabled. The collision avoidance policy tweaks the next delay by a random amount, up to plus/minus p% of its current value. The default is 0.15.

Delay Pattern

Specifies a pattern to use for calculating the delay, which enables you to specify fixed delays for interval groups. For example, the pattern 0:1000; 5:5000; 10:30000 specifies a 1 second delay between redelivery attempts 0 through 4, a 5 second delay between attempts 5 through 9, and a 30 second delay between all subsequent attempts.

Disable Redelivery

Specifies whether to disable the redelivery feature. Redelivery is enabled when Maximum Redeliveries is set to a positive number.

Log Continued

Specifies whether to log continuously reoccurring exceptions. The default is false.

Log Exhausted

Specifies whether to log all failed redelivery attempts. The default is true.

Log Handled

Specifies whether to log handled exceptions. The default is false.

Log Retry Attempted

Specifies whether to log redelivery attempts. The default is true.

Log Retry Stack Trace

Specifies whether to log stack traces for failed delivery attempts. The default is false.

Log Stack Trace

Specifies whether to include the JVM stack trace in the error logs. The default is true.

Maximum Redeliveries

Specifies the maximum number of delivery attempts. The default is 0.

Maximum Redelivery Delay

Specifies, in milliseconds, the maximum redelivery delay when using an exponential back-off strategy. The default is 60 * 1000.

Redelivery Delay

Specifies the delay, in milliseconds, between redelivery attempts. The default is 1000.

Retries Exhausted Log Level

Specifies the logging level at which to log delivery failure. The default is Error.

Retry Attempted Log Level

Specifies the logging level at which to redelivery attempts. The default is Debug.

Use Collision Avoidance

Specifies whether to use collision avoidance, which adds some randomization to the back-off timings, reducing the probability of contention. The default is false

Use Exponential Back Off

Specifies whether to use exponential backoff. The default is false.


Related topics