Table of Contents
Route to be executed when an exception is thrown
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 |
|---|---|
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.
Table 68, “On Exception Properties” describes the properties you can specify using the properties editor.
Table 68. On Exception Properties
| Name | Description |
|---|---|
| Specifies the list of exceptions the node handles. The button adds an entry typed in the field. The button removes the selected entry from the list. |
| Specifies the expression language used to process the continued expression. |
| 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. |
| Specifies the expression language used to process the expression. |
| 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. |
| Specifies a reference to a processor that should be processed just after an exception occured. |
| Specifies a reference to a custom processor for processing the message before it is redelivered. |
| 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. |
| Specifies how to handle failed deliveries. Redelivery options are listed in Table 69, “Redelivery Properties”. |
| Specifies a reference to bean defining the redelivery 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
| Name | Description |
|---|---|
| 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. |
| 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. |
| Specifies the multiplier used to determine the redelivery delay if exponential
back-off is enabled. If d, m*d, m*m*d, m*m*m*d, ... The default is 2. |
| 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 |
| Specifies a pattern to use for calculating the delay, which enables you to
specify fixed delays for interval groups. For example, the pattern |
| Specifies whether to disable the redelivery feature. Redelivery is enabled when
|
| Specifies whether to log continuously reoccurring exceptions. The default is false. |
| Specifies whether to log all failed redelivery attempts. The default is true. |
| Specifies whether to log handled exceptions. The default is false. |
| Specifies whether to log redelivery attempts. The default is true. |
| Specifies whether to log stack traces for failed delivery attempts. The default is false. |
| Specifies whether to include the JVM stack trace in the error logs. The default is true. |
| Specifies the maximum number of delivery attempts. The default is 0. |
| Specifies, in milliseconds, the maximum redelivery delay when using an exponential back-off strategy. The default is 60 * 1000. |
| Specifies the delay, in milliseconds, between redelivery attempts. The default is 1000. |
| Specifies the logging level at which to log delivery failure. The default is Error. |
| Specifies the logging level at which to redelivery attempts. The default is Debug. |
| Specifies whether to use collision avoidance, which adds some randomization to the back-off timings, reducing the probability of contention. The default is false |
| Specifies whether to use exponential backoff. The default is false. |