org.apache.camel.model
Class OnExceptionDefinition

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

public class OnExceptionDefinition
extends ProcessorDefinition<ProcessorDefinition>

Represents an XML <onException/> element

Version:
$Revision: 797459 $

Field Summary
 
Fields inherited from class org.apache.camel.model.ProcessorDefinition
log
 
Constructor Summary
OnExceptionDefinition()
           
OnExceptionDefinition(Class exceptionType)
           
OnExceptionDefinition(List<Class> exceptionClasses)
           
 
Method Summary
 void addRoutes(RouteContext routeContext, Collection<Route> routes)
           
 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
protected  List<Class> createExceptionClasses()
           
 CatchProcessor createProcessor(RouteContext routeContext)
           
 RedeliveryPolicy createRedeliveryPolicy(CamelContext context, RedeliveryPolicy parentPolicy)
          Allows an exception handler to create a new redelivery policy for this exception type
 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 getRetryUntil()
           
 Predicate getRetryUntilPolicy()
           
 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.
 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 cathing certain exceptions and handling them.
 OnExceptionDefinition onRedelivery(Processor processor)
          Sets a processor that should be processed before a redelivey 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)
          Sets the delay
 OnExceptionDefinition redeliveryDelay(long delay)
          Sets the fixed delay between redeliveries
 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 retryUntil(Expression until)
          Sets the retry until expression.
 OnExceptionDefinition retryUntil(Predicate until)
          Sets the retry until predicate.
 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 setRetryUntil(ExpressionSubElementDefinition retryUntil)
           
 void setRetryUntilPolicy(Predicate retryUntilPolicy)
           
 void setUseOriginalMessagePolicy(Boolean useOriginalMessagePolicy)
           
 String toString()
           
 OnExceptionDefinition useCollisionAvoidance()
          Turn on collision avoidance.
 OnExceptionDefinition useExponentialBackOff()
          Turn on exponential backk off
 OnExceptionDefinition useOriginalBody()
          Will use the original input body 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, aggregate, aop, bean, bean, bean, bean, beanRef, beanRef, choice, clearOutput, configureChild, convertBodyTo, convertBodyTo, createChannel, createCompositeProcessor, createErrorHandlerBuilder, createOutputsProcessor, createOutputsProcessor, delay, delay, delay, doTry, end, enrich, enrich, errorHandler, filter, filter, filter, filter, getErrorHandlerBuilder, getErrorHandlerRef, getInterceptStrategies, getLabel, getNodeFactory, getParent, id, idempotentConsumer, idempotentConsumer, idempotentConsumer, inOnly, inOnly, inOnly, inOnly, inOnly, inOnly, inOut, inOut, inOut, inOut, inOut, inOut, loadBalance, loadBalance, loop, loop, loop, makeProcessor, marshal, marshal, marshal, marshal, multicast, multicast, multicast, onCompletion, pipeline, pipeline, pipeline, policy, policy, pollEnrich, pollEnrich, pollEnrich, pollEnrich, process, processRef, recipientList, recipientList, removeFaultHeader, removeHeader, removeProperty, resequence, resequence, resequence, resequencer, rollback, rollback, routingSlip, routingSlip, setBody, setBody, setErrorHandlerBuilder, setErrorHandlerBuilderIfNull, setErrorHandlerRef, setExchangePattern, setFaultBody, setFaultHeader, setHeader, setHeader, setNodeFactory, setOutHeader, setOutHeader, setParent, setProperty, setProperty, sort, sort, sortBody, sortBody, split, split, split, stop, threads, threads, throttle, throwException, to, to, to, to, to, to, to, to, to, to, toF, transacted, transacted, transform, transform, unmarshal, unmarshal, unmarshal, unmarshal, wireTap, wireTap, wireTap, wrapChannel, wrapProcessor
 
Methods inherited from class org.apache.camel.model.OptionalIdentifiedDefinition
description, getDescription, 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<ProcessorDefinition>
Returns:
defaults to "node" but derived nodes should overload this to provide a unique name

toString

public String toString()
Overrides:
toString in class Object

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<ProcessorDefinition>
Throws:
Exception

createProcessor

public CatchProcessor createProcessor(RouteContext routeContext)
                               throws Exception
Overrides:
createProcessor in class ProcessorDefinition<ProcessorDefinition>
Throws:
Exception

onException

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

Overrides:
onException in class ProcessorDefinition<ProcessorDefinition>
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

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

retryUntil

public OnExceptionDefinition retryUntil(Predicate until)
Sets the retry until predicate.

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

retryUntil

public OnExceptionDefinition retryUntil(Expression until)
Sets the retry until expression.

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

redeliverDelay

public OnExceptionDefinition redeliverDelay(long delay)
Sets the delay

Parameters:
delay - the redeliver 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 fixed delay between redeliveries

Parameters:
delay - delay in millis
Returns:
the builder

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

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

useOriginalBody

public OnExceptionDefinition useOriginalBody()
Will use the original input body 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 redelivey attempt.

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


getOutputs

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

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)

getHandled

public ExpressionSubElementDefinition getHandled()

setHandledPolicy

public void setHandledPolicy(Predicate handledPolicy)

getOnWhen

public WhenDefinition getOnWhen()

setOnWhen

public void setOnWhen(WhenDefinition onWhen)

getRetryUntil

public ExpressionSubElementDefinition getRetryUntil()

setRetryUntil

public void setRetryUntil(ExpressionSubElementDefinition retryUntil)

getRetryUntilPolicy

public Predicate getRetryUntilPolicy()

setRetryUntilPolicy

public void setRetryUntilPolicy(Predicate retryUntilPolicy)

getOnRedelivery

public Processor getOnRedelivery()

setOnRedelivery

public void setOnRedelivery(Processor onRedelivery)

getOnRedeliveryRef

public String getOnRedeliveryRef()

setOnRedeliveryRef

public void setOnRedeliveryRef(String onRedeliveryRef)

getUseOriginalMessagePolicy

public Boolean getUseOriginalMessagePolicy()

setUseOriginalMessagePolicy

public void setUseOriginalMessagePolicy(Boolean useOriginalMessagePolicy)

getOrCreateRedeliveryPolicy

protected RedeliveryPolicyDefinition getOrCreateRedeliveryPolicy()

createExceptionClasses

protected List<Class> createExceptionClasses()


Apache CAMEL