org.apache.camel.model
Class OnExceptionDefinition

java.lang.Object
  extended by org.apache.camel.model.OptionalIdentifiedDefinition
      extended by org.apache.camel.model.ProcessorDefinition<OnExceptionDefinition>
          extended by org.apache.camel.model.OnExceptionDefinition
All Implemented Interfaces:
Block

public class OnExceptionDefinition
extends ProcessorDefinition<OnExceptionDefinition>

Represents an XML <onException/> element

Version:
$Revision: 1021867 $

Field Summary
 
Fields inherited from class org.apache.camel.model.ProcessorDefinition
errorHandlerBuilder, errorHandlerRef, inheritErrorHandler, log
 
Constructor Summary
OnExceptionDefinition()
           
OnExceptionDefinition(Class exceptionType)
           
OnExceptionDefinition(List<Class> exceptionClasses)
           
 
Method Summary
 void addRoutes(RouteContext routeContext, Collection<Route> routes)
           
 OnExceptionDefinition asyncDelayedRedelivery()
          Allow synchronous delayed redelivery.
 OnExceptionDefinition backOffMultiplier(double backOffMultiplier)
          Sets the back off multiplier
 OnExceptionDefinition collisionAvoidanceFactor(double collisionAvoidanceFactor)
          Sets the collision avoidance factor
 OnExceptionDefinition collisionAvoidancePercent(double collisionAvoidancePercent)
          Sets the collision avoidance percentage
 OnExceptionDefinition continued(boolean continued)
          Sets whether the exchange should handle and continue routing from the point of failure.
 OnExceptionDefinition continued(Expression continued)
          Sets whether the exchange should be marked as handled or not.
 OnExceptionDefinition continued(Predicate continued)
          Sets whether the exchange should be marked as handled or not.
protected  List<Class> createExceptionClasses()
           
 CatchProcessor createProcessor(RouteContext routeContext)
          Override this in definition class and implement logic to create the processor based on the definition model.
 RedeliveryPolicy createRedeliveryPolicy(CamelContext context, RedeliveryPolicy parentPolicy)
          Allows an exception handler to create a new redelivery policy for this exception type
 OnExceptionDefinition delayPattern(String delayPattern)
          Sets the delay pattern with delay intervals.
 ExpressionSubElementDefinition getContinued()
           
 Predicate getContinuedPolicy()
           
 Processor getErrorHandler()
           
 List<Class> getExceptionClasses()
           
 List<String> getExceptions()
           
 ExpressionSubElementDefinition getHandled()
           
 Predicate getHandledPolicy()
           
 Processor getOnRedelivery()
           
 String getOnRedeliveryRef()
           
 WhenDefinition getOnWhen()
           
protected  RedeliveryPolicyDefinition getOrCreateRedeliveryPolicy()
           
 List<ProcessorDefinition> getOutputs()
           
 RedeliveryPolicyDefinition getRedeliveryPolicy()
           
 ExpressionSubElementDefinition getRetryWhile()
           
 Predicate getRetryWhilePolicy()
           
 String getShortName()
          Returns a short name for this node which can be useful for ID generation or referring to related resources like images
 Boolean getUseOriginalMessagePolicy()
           
 OnExceptionDefinition handled(boolean handled)
          Sets whether the exchange should be marked as handled or not.
 OnExceptionDefinition handled(Expression handled)
          Sets whether the exchange should be marked as handled or not.
 OnExceptionDefinition handled(Predicate handled)
          Sets whether the exchange should be marked as handled or not.
 boolean isAbstract()
          Whether this model is abstract or not.
 boolean isAsyncDelayedRedelivery()
           
 boolean isUseOriginalMessage()
           
 OnExceptionDefinition logContinued(boolean logContinued)
          Sets whether to log errors even if its continued
 OnExceptionDefinition logExhausted(boolean logExhausted)
          Sets whether to log exhausted exceptions
 OnExceptionDefinition logHandled(boolean logHandled)
          Sets whether to log errors even if its handled
 OnExceptionDefinition logRetryAttempted(boolean logRetryAttempted)
          Sets whether to log retry attempts
 OnExceptionDefinition logRetryStackTrace(boolean logRetryStackTrace)
          Sets whether to log stacktrace for failed redelivery attempts
 OnExceptionDefinition logStackTrace(boolean logStackTrace)
          Sets whether to log stacktrace for failed messages.
 OnExceptionDefinition maximumRedeliveries(int maximumRedeliveries)
          Sets the maximum redeliveries 5 = default value 0 = no redeliveries -1 = redeliver forever
 OnExceptionDefinition maximumRedeliveryDelay(long maximumRedeliveryDelay)
          Sets the maximum delay between redelivery
 OnExceptionDefinition onException(Class exceptionType)
          Exception clause for catching certain exceptions and handling them.
 OnExceptionDefinition onRedelivery(Processor processor)
          Sets a processor that should be processed before a redelivery attempt.
 ExpressionClause<OnExceptionDefinition> onWhen()
          Creates an expression to configure an additional predicate that should be true before the onException is triggered.
 OnExceptionDefinition onWhen(Predicate predicate)
          Sets an additional predicate that should be true before the onException is triggered.
 OnExceptionDefinition redeliverDelay(long delay)
          Deprecated.  
 OnExceptionDefinition redeliveryDelay(long delay)
          Sets the initial redelivery delay
 OnExceptionDefinition redeliveryPolicyRef(String redeliveryPolicyRef)
          Sets a reference to a RedeliveryPolicy to lookup in the Registry to be used.
 OnExceptionDefinition retriesExhaustedLogLevel(LoggingLevel retriesExhaustedLogLevel)
          Sets the logging level to use when retries has exhausted
 OnExceptionDefinition retryAttemptedLogLevel(LoggingLevel retryAttemptedLogLevel)
          Sets the logging level to use for logging retry attempts
 OnExceptionDefinition retryWhile(Expression retryWhile)
          Sets the retry while expression.
 OnExceptionDefinition retryWhile(Predicate retryWhile)
          Sets the retry while predicate.
 void setContinued(ExpressionSubElementDefinition continued)
           
 void setContinuedPolicy(Predicate continuedPolicy)
           
 void setExceptionClasses(List<Class> exceptionClasses)
           
 void setExceptions(List<String> exceptions)
           
 void setHandled(ExpressionSubElementDefinition handled)
           
 void setHandledPolicy(Predicate handledPolicy)
           
 void setOnRedelivery(Processor onRedelivery)
           
 void setOnRedeliveryRef(String onRedeliveryRef)
           
 void setOnWhen(WhenDefinition onWhen)
           
 void setOutputs(List<ProcessorDefinition> outputs)
           
 void setRedeliveryPolicy(RedeliveryPolicyDefinition redeliveryPolicy)
           
 void setRetryWhile(ExpressionSubElementDefinition retryWhile)
           
 void setRetryWhilePolicy(Predicate retryWhilePolicy)
           
 void setUseOriginalMessagePolicy(Boolean useOriginalMessagePolicy)
           
 String toString()
           
 OnExceptionDefinition useCollisionAvoidance()
          Turn on collision avoidance.
 OnExceptionDefinition useExponentialBackOff()
          Turn on exponential backk off
 OnExceptionDefinition useOriginalBody()
          Deprecated. this method will be removed in Camel 3.0, please use useOriginalMessage()
 OnExceptionDefinition useOriginalMessage()
          Will use the original input message when an Exchange is moved to the dead letter queue.
 
Methods inherited from class org.apache.camel.model.ProcessorDefinition
addInterceptStrategies, addInterceptStrategy, addOutput, aggregate, aggregate, aggregate, aggregate, aop, bean, bean, bean, bean, beanRef, beanRef, choice, clearOutput, configureChild, convertBodyTo, convertBodyTo, createChannel, createChildProcessor, createCompositeProcessor, createErrorHandlerBuilder, createOutputsProcessor, createOutputsProcessor, delay, delay, delay, doTry, dynamicRouter, dynamicRouter, end, enrich, enrich, enrichRef, filter, filter, filter, filter, getErrorHandlerBuilder, getInterceptStrategies, getLabel, getNodeFactory, getParent, id, idempotentConsumer, idempotentConsumer, idempotentConsumer, inheritErrorHandler, inOnly, inOnly, inOnly, inOnly, inOnly, inOnly, inOut, inOut, inOut, inOut, inOut, inOut, isInheritErrorHandler, loadBalance, loadBalance, log, log, log, loop, loop, loop, makeProcessor, markRollbackOnly, markRollbackOnlyLast, marshal, marshal, marshal, marshal, multicast, multicast, multicast, onCompletion, onException, pipeline, pipeline, pipeline, pipeline, policy, policy, pollEnrich, pollEnrich, pollEnrich, pollEnrich, pollEnrichRef, process, processRef, recipientList, recipientList, recipientList, removeFaultHeader, removeHeader, removeHeaders, removeProperty, resequence, resequence, resequence, resequence, resolvePropertyPlaceholders, rollback, rollback, routeId, routingSlip, routingSlip, routingSlip, routingSlip, routingSlip, routingSlip, routingSlip, sample, sample, setBody, setBody, setErrorHandlerBuilder, setExchangePattern, setFaultBody, setFaultHeader, setHeader, setHeader, setInheritErrorHandler, setNodeFactory, setOutHeader, setOutHeader, setParent, setProperty, setProperty, sort, sort, sortBody, sortBody, split, split, split, stop, threads, threads, threads, throttle, throwException, to, to, to, to, to, to, to, to, to, to, toF, transacted, transacted, transform, transform, unmarshal, unmarshal, unmarshal, unmarshal, validate, validate, validate, wireTap, wireTap, wireTap, wireTap, wireTap, wireTap, wireTap, wrapChannel, wrapInErrorHandler, wrapProcessor
 
Methods inherited from class org.apache.camel.model.OptionalIdentifiedDefinition
description, getDescription, getDescriptionText, getId, hasCustomIdAssigned, idOrCreate, setDescription, setId
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

OnExceptionDefinition

public OnExceptionDefinition()

OnExceptionDefinition

public OnExceptionDefinition(List<Class> exceptionClasses)

OnExceptionDefinition

public OnExceptionDefinition(Class exceptionType)
Method Detail

getShortName

public String getShortName()
Description copied from class: OptionalIdentifiedDefinition
Returns a short name for this node which can be useful for ID generation or referring to related resources like images

Overrides:
getShortName in class OptionalIdentifiedDefinition
Returns:
defaults to "node" but derived nodes should overload this to provide a unique name

toString

public String toString()
Overrides:
toString in class Object

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<OnExceptionDefinition>
Returns:
true for abstract, otherwise false for regular.

createRedeliveryPolicy

public RedeliveryPolicy createRedeliveryPolicy(CamelContext context,
                                               RedeliveryPolicy parentPolicy)
Allows an exception handler to create a new redelivery policy for this exception type

Parameters:
context - the camel context
parentPolicy - the current redelivery policy
Returns:
a newly created redelivery policy, or return the original policy if no customization is required for this exception handler.

addRoutes

public void addRoutes(RouteContext routeContext,
                      Collection<Route> routes)
               throws Exception
Overrides:
addRoutes in class ProcessorDefinition<OnExceptionDefinition>
Throws:
Exception

createProcessor

public CatchProcessor createProcessor(RouteContext routeContext)
                               throws Exception
Description copied from class: ProcessorDefinition
Override this in definition class and implement logic to create the processor based on the definition model.

Overrides:
createProcessor in class ProcessorDefinition<OnExceptionDefinition>
Throws:
Exception

onException

public OnExceptionDefinition onException(Class exceptionType)
Description copied from class: ProcessorDefinition
Exception clause for catching certain exceptions and handling them.

Overrides:
onException in class ProcessorDefinition<OnExceptionDefinition>
Parameters:
exceptionType - the exception to catch
Returns:
the exception builder to configure

handled

public OnExceptionDefinition handled(boolean handled)
Sets whether the exchange should be marked as handled or not.

Parameters:
handled - handled or not
Returns:
the builder

handled

public OnExceptionDefinition handled(Predicate handled)
Sets whether the exchange should be marked as handled or not.

Parameters:
handled - predicate that determines true or false
Returns:
the builder

handled

public OnExceptionDefinition handled(Expression handled)
Sets whether the exchange should be marked as handled or not.

Parameters:
handled - expression that determines true or false
Returns:
the builder

continued

public OnExceptionDefinition continued(boolean continued)
Sets whether the exchange should handle and continue routing from the point of failure.

If this option is enabled then its considered handled as well.

Parameters:
continued - continued or not
Returns:
the builder

continued

public OnExceptionDefinition continued(Predicate continued)
Sets whether the exchange should be marked as handled or not.

If this option is enabled then its considered handled as well.

Parameters:
continued - predicate that determines true or false
Returns:
the builder

continued

public OnExceptionDefinition continued(Expression continued)
Sets whether the exchange should be marked as handled or not.

If this option is enabled then its considered handled as well.

Parameters:
continued - expression that determines true or false
Returns:
the builder

onWhen

public OnExceptionDefinition onWhen(Predicate predicate)
Sets an additional predicate that should be true before the onException is triggered.

To be used for fine grained controlling whether a thrown exception should be intercepted by this exception type or not.

Parameters:
predicate - predicate that determines true or false
Returns:
the builder

onWhen

public ExpressionClause<OnExceptionDefinition> onWhen()
Creates an expression to configure an additional predicate that should be true before the onException is triggered.

To be used for fine grained controlling whether a thrown exception should be intercepted by this exception type or not.

Returns:
the expression clause to configure

retryWhile

public OnExceptionDefinition retryWhile(Predicate retryWhile)
Sets the retry while predicate.

Will continue retrying until predicate returns false.

Parameters:
retryWhile - predicate that determines when to stop retrying
Returns:
the builder

retryWhile

public OnExceptionDefinition retryWhile(Expression retryWhile)
Sets the retry while expression.

Will continue retrying until expression evaluates to false.

Parameters:
retryWhile - expression that determines when to stop retrying
Returns:
the builder

redeliverDelay

@Deprecated
public OnExceptionDefinition redeliverDelay(long delay)
Deprecated. 

Sets the initial redelivery delay

Parameters:
delay - the initial redelivery delay
Returns:
the builder

backOffMultiplier

public OnExceptionDefinition backOffMultiplier(double backOffMultiplier)
Sets the back off multiplier

Parameters:
backOffMultiplier - the back off multiplier
Returns:
the builder

collisionAvoidanceFactor

public OnExceptionDefinition collisionAvoidanceFactor(double collisionAvoidanceFactor)
Sets the collision avoidance factor

Parameters:
collisionAvoidanceFactor - the factor
Returns:
the builder

collisionAvoidancePercent

public OnExceptionDefinition collisionAvoidancePercent(double collisionAvoidancePercent)
Sets the collision avoidance percentage

Parameters:
collisionAvoidancePercent - the percentage
Returns:
the builder

redeliveryDelay

public OnExceptionDefinition redeliveryDelay(long delay)
Sets the initial redelivery delay

Parameters:
delay - delay in millis
Returns:
the builder

asyncDelayedRedelivery

public OnExceptionDefinition asyncDelayedRedelivery()
Allow synchronous delayed redelivery.

Returns:
the builder
See Also:
RedeliveryPolicy.setAsyncDelayedRedelivery(boolean)

retriesExhaustedLogLevel

public OnExceptionDefinition retriesExhaustedLogLevel(LoggingLevel retriesExhaustedLogLevel)
Sets the logging level to use when retries has exhausted

Parameters:
retriesExhaustedLogLevel - the logging level
Returns:
the builder

retryAttemptedLogLevel

public OnExceptionDefinition retryAttemptedLogLevel(LoggingLevel retryAttemptedLogLevel)
Sets the logging level to use for logging retry attempts

Parameters:
retryAttemptedLogLevel - the logging level
Returns:
the builder

logStackTrace

public OnExceptionDefinition logStackTrace(boolean logStackTrace)
Sets whether to log stacktrace for failed messages.


logRetryStackTrace

public OnExceptionDefinition logRetryStackTrace(boolean logRetryStackTrace)
Sets whether to log stacktrace for failed redelivery attempts


logHandled

public OnExceptionDefinition logHandled(boolean logHandled)
Sets whether to log errors even if its handled


logContinued

public OnExceptionDefinition logContinued(boolean logContinued)
Sets whether to log errors even if its continued


logRetryAttempted

public OnExceptionDefinition logRetryAttempted(boolean logRetryAttempted)
Sets whether to log retry attempts


logExhausted

public OnExceptionDefinition logExhausted(boolean logExhausted)
Sets whether to log exhausted exceptions


maximumRedeliveries

public OnExceptionDefinition maximumRedeliveries(int maximumRedeliveries)
Sets the maximum redeliveries

Parameters:
maximumRedeliveries - the value
Returns:
the builder

useCollisionAvoidance

public OnExceptionDefinition useCollisionAvoidance()
Turn on collision avoidance.

Returns:
the builder

useExponentialBackOff

public OnExceptionDefinition useExponentialBackOff()
Turn on exponential backk off

Returns:
the builder

maximumRedeliveryDelay

public OnExceptionDefinition maximumRedeliveryDelay(long maximumRedeliveryDelay)
Sets the maximum delay between redelivery

Parameters:
maximumRedeliveryDelay - the delay in millis
Returns:
the builder

redeliveryPolicyRef

public OnExceptionDefinition redeliveryPolicyRef(String redeliveryPolicyRef)
Sets a reference to a RedeliveryPolicy to lookup in the Registry to be used.

Parameters:
redeliveryPolicyRef - reference to use for lookup
Returns:
the builder

delayPattern

public OnExceptionDefinition delayPattern(String delayPattern)
Sets the delay pattern with delay intervals.

Parameters:
delayPattern - the delay pattern
Returns:
the builder

useOriginalBody

@Deprecated
public OnExceptionDefinition useOriginalBody()
Deprecated. this method will be removed in Camel 3.0, please use useOriginalMessage()

See Also:
useOriginalMessage()

useOriginalMessage

public OnExceptionDefinition useOriginalMessage()
Will use the original input message when an Exchange is moved to the dead letter queue.

Notice: this only applies when all redeliveries attempt have failed and the Exchange is doomed for failure.
Instead of using the current inprogress Exchange IN body we use the original IN body instead. This allows you to store the original input in the dead letter queue instead of the inprogress snapshot of the IN body. For instance if you route transform the IN body during routing and then failed. With the original exchange store in the dead letter queue it might be easier to manually re submit the Exchange again as the IN body is the same as when Camel received it. So you should be able to send the Exchange to the same input.

By default this feature is off.

Returns:
the builder

onRedelivery

public OnExceptionDefinition onRedelivery(Processor processor)
Sets a processor that should be processed before a redelivery attempt.

Can be used to change the Exchange before its being redelivered.


getOutputs

public List<ProcessorDefinition> getOutputs()
Specified by:
getOutputs in class ProcessorDefinition<OnExceptionDefinition>

setOutputs

public void setOutputs(List<ProcessorDefinition> outputs)

getExceptionClasses

public List<Class> getExceptionClasses()

setExceptionClasses

public void setExceptionClasses(List<Class> exceptionClasses)

getExceptions

public List<String> getExceptions()

setExceptions

public void setExceptions(List<String> exceptions)

getErrorHandler

public Processor getErrorHandler()

getRedeliveryPolicy

public RedeliveryPolicyDefinition getRedeliveryPolicy()

setRedeliveryPolicy

public void setRedeliveryPolicy(RedeliveryPolicyDefinition redeliveryPolicy)

getHandledPolicy

public Predicate getHandledPolicy()

setHandled

public void setHandled(ExpressionSubElementDefinition handled)

getContinued

public ExpressionSubElementDefinition getContinued()

setContinued

public void setContinued(ExpressionSubElementDefinition continued)

getHandled

public ExpressionSubElementDefinition getHandled()

setHandledPolicy

public void setHandledPolicy(Predicate handledPolicy)

getContinuedPolicy

public Predicate getContinuedPolicy()

setContinuedPolicy

public void setContinuedPolicy(Predicate continuedPolicy)

getOnWhen

public WhenDefinition getOnWhen()

setOnWhen

public void setOnWhen(WhenDefinition onWhen)

getRetryWhile

public ExpressionSubElementDefinition getRetryWhile()

setRetryWhile

public void setRetryWhile(ExpressionSubElementDefinition retryWhile)

getRetryWhilePolicy

public Predicate getRetryWhilePolicy()

setRetryWhilePolicy

public void setRetryWhilePolicy(Predicate retryWhilePolicy)

getOnRedelivery

public Processor getOnRedelivery()

setOnRedelivery

public void setOnRedelivery(Processor onRedelivery)

getOnRedeliveryRef

public String getOnRedeliveryRef()

setOnRedeliveryRef

public void setOnRedeliveryRef(String onRedeliveryRef)

getUseOriginalMessagePolicy

public Boolean getUseOriginalMessagePolicy()

isUseOriginalMessage

public boolean isUseOriginalMessage()

setUseOriginalMessagePolicy

public void setUseOriginalMessagePolicy(Boolean useOriginalMessagePolicy)

isAsyncDelayedRedelivery

public boolean isAsyncDelayedRedelivery()

getOrCreateRedeliveryPolicy

protected RedeliveryPolicyDefinition getOrCreateRedeliveryPolicy()

createExceptionClasses

protected List<Class> createExceptionClasses()


Apache CAMEL