org.apache.camel.builder
Class DefaultErrorHandlerBuilder

java.lang.Object
  extended by org.apache.camel.builder.ErrorHandlerBuilderSupport
      extended by org.apache.camel.builder.DefaultErrorHandlerBuilder
All Implemented Interfaces:
ErrorHandlerBuilder
Direct Known Subclasses:
DeadLetterChannelBuilder, TransactionErrorHandlerBuilder

public class DefaultErrorHandlerBuilder
extends ErrorHandlerBuilderSupport

The default error handler builder.

Version:

Field Summary
protected  boolean asyncDelayedRedelivery
           
protected  Endpoint deadLetter
           
protected  String deadLetterUri
           
protected  ExceptionPolicyStrategy exceptionPolicyStrategy
           
protected  Processor failureProcessor
           
protected  Predicate handledPolicy
           
protected  CamelLogger logger
           
protected  Processor onRedelivery
           
protected  RedeliveryPolicy redeliveryPolicy
           
protected  Predicate retryWhile
           
protected  String retryWhileRef
           
protected  boolean useOriginalMessage
           
 
Constructor Summary
DefaultErrorHandlerBuilder()
           
 
Method Summary
 DefaultErrorHandlerBuilder asyncDelayedRedelivery()
          Will allow asynchronous delayed redeliveries.
 DefaultErrorHandlerBuilder backOffMultiplier(double backOffMultiplier)
           
 DefaultErrorHandlerBuilder collisionAvoidancePercent(double collisionAvoidancePercent)
           
 Processor createErrorHandler(RouteContext routeContext, Processor processor)
          Creates the error handler interceptor
protected  Predicate createHandledPolicy()
           
protected  CamelLogger createLogger()
           
protected  RedeliveryPolicy createRedeliveryPolicy()
           
 DefaultErrorHandlerBuilder delayPattern(String delayPattern)
           
 DefaultErrorHandlerBuilder disableRedelivery()
           
 DefaultErrorHandlerBuilder exceptionPolicyStrategy(ExceptionPolicyStrategy exceptionPolicyStrategy)
          Sets the exception policy to use
 Endpoint getDeadLetter()
           
 String getDeadLetterUri()
           
 ExceptionPolicyStrategy getExceptionPolicyStrategy()
          Sets the exception policy strategy to use for resolving the OnExceptionDefinition to use for a given thrown exception
 Processor getFailureProcessor()
           
 Predicate getHandledPolicy()
          Deprecated. 
 CamelLogger getLogger()
           
 Processor getOnRedelivery()
           
 RedeliveryPolicy getRedeliveryPolicy()
           
 Predicate getRetryWhile()
           
 Predicate getRetryWhilePolicy(CamelContext context)
           
 String getRetryWhileRef()
           
 DefaultErrorHandlerBuilder handled(boolean handled)
          Deprecated. 
 DefaultErrorHandlerBuilder handled(Expression handled)
          Deprecated. 
 DefaultErrorHandlerBuilder handled(Predicate handled)
          Deprecated. 
 boolean isAsyncDelayedRedelivery()
           
 boolean isUseOriginalMessage()
           
 DefaultErrorHandlerBuilder log(Class<?> log)
          Sets the log used for caught exceptions
 DefaultErrorHandlerBuilder log(org.slf4j.Logger log)
          Sets the log used for caught exceptions
 DefaultErrorHandlerBuilder log(String log)
          Sets the log used for caught exceptions
 DefaultErrorHandlerBuilder logExhausted(boolean logExhausted)
           
 DefaultErrorHandlerBuilder logger(CamelLogger logger)
          Sets the logger used for caught exceptions
 DefaultErrorHandlerBuilder loggingLevel(LoggingLevel level)
          Sets the logging level of exceptions caught
 DefaultErrorHandlerBuilder logHandled(boolean logHandled)
           
 DefaultErrorHandlerBuilder logRetryStackTrace(boolean logRetryStackTrace)
           
 DefaultErrorHandlerBuilder logStackTrace(boolean logStackTrace)
           
 DefaultErrorHandlerBuilder maximumRedeliveries(int maximumRedeliveries)
           
 DefaultErrorHandlerBuilder maximumRedeliveryDelay(long maximumRedeliveryDelay)
           
 DefaultErrorHandlerBuilder onRedelivery(Processor processor)
          Sets a processor that should be processed before a redelivery attempt.
 DefaultErrorHandlerBuilder redeliverDelay(long delay)
          Deprecated. 
 DefaultErrorHandlerBuilder redeliveryDelay(long delay)
           
 DefaultErrorHandlerBuilder retriesExhaustedLogLevel(LoggingLevel retriesExhaustedLogLevel)
           
 DefaultErrorHandlerBuilder retryAttemptedLogLevel(LoggingLevel retryAttemptedLogLevel)
           
 DefaultErrorHandlerBuilder retryWhile(Expression retryWhile)
          Sets the retry while expression.
 void setAsyncDelayedRedelivery(boolean asyncDelayedRedelivery)
           
 void setDeadLetter(Endpoint deadLetter)
           
 void setDeadLetterUri(String deadLetterUri)
           
 void setExceptionPolicyStrategy(ExceptionPolicyStrategy exceptionPolicyStrategy)
          Sets the exception policy strategy to use for resolving the OnExceptionDefinition to use for a given thrown exception
 void setFailureProcessor(Processor failureProcessor)
           
 void setHandled(boolean handled)
          Deprecated. 
 void setHandledPolicy(Predicate handled)
          Deprecated. 
 void setLogger(CamelLogger logger)
           
 void setOnRedelivery(Processor onRedelivery)
           
 void setRedeliveryPolicy(RedeliveryPolicy redeliveryPolicy)
          Sets the redelivery policy
 void setRetryWhile(Predicate retryWhile)
           
 void setRetryWhileRef(String retryWhileRef)
           
 void setUseOriginalMessage(boolean useOriginalMessage)
           
 boolean supportTransacted()
          Whether this error handler supports transacted exchanges.
 String toString()
           
 DefaultErrorHandlerBuilder useCollisionAvoidance()
           
 DefaultErrorHandlerBuilder useExponentialBackOff()
           
 DefaultErrorHandlerBuilder useOriginalMessage()
          Will use the original input Message when an Exchange is moved to the dead letter queue.
 
Methods inherited from class org.apache.camel.builder.ErrorHandlerBuilderSupport
addErrorHandlers, configure, getErrorHandlers, setErrorHandlers
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

logger

protected CamelLogger logger

exceptionPolicyStrategy

protected ExceptionPolicyStrategy exceptionPolicyStrategy

redeliveryPolicy

protected RedeliveryPolicy redeliveryPolicy

onRedelivery

protected Processor onRedelivery

handledPolicy

protected Predicate handledPolicy

retryWhile

protected Predicate retryWhile

retryWhileRef

protected String retryWhileRef

failureProcessor

protected Processor failureProcessor

deadLetter

protected Endpoint deadLetter

deadLetterUri

protected String deadLetterUri

useOriginalMessage

protected boolean useOriginalMessage

asyncDelayedRedelivery

protected boolean asyncDelayedRedelivery
Constructor Detail

DefaultErrorHandlerBuilder

public DefaultErrorHandlerBuilder()
Method Detail

createErrorHandler

public Processor createErrorHandler(RouteContext routeContext,
                                    Processor processor)
                             throws Exception
Description copied from interface: ErrorHandlerBuilder
Creates the error handler interceptor

Parameters:
routeContext - the route context
processor - the outer processor
Returns:
the error handler
Throws:
Exception - is thrown if the error handler could not be created

supportTransacted

public boolean supportTransacted()
Description copied from interface: ErrorHandlerBuilder
Whether this error handler supports transacted exchanges.


backOffMultiplier

public DefaultErrorHandlerBuilder backOffMultiplier(double backOffMultiplier)

collisionAvoidancePercent

public DefaultErrorHandlerBuilder collisionAvoidancePercent(double collisionAvoidancePercent)

redeliverDelay

@Deprecated
public DefaultErrorHandlerBuilder redeliverDelay(long delay)
Deprecated. 


redeliveryDelay

public DefaultErrorHandlerBuilder redeliveryDelay(long delay)

delayPattern

public DefaultErrorHandlerBuilder delayPattern(String delayPattern)

maximumRedeliveries

public DefaultErrorHandlerBuilder maximumRedeliveries(int maximumRedeliveries)

disableRedelivery

public DefaultErrorHandlerBuilder disableRedelivery()

maximumRedeliveryDelay

public DefaultErrorHandlerBuilder maximumRedeliveryDelay(long maximumRedeliveryDelay)

useCollisionAvoidance

public DefaultErrorHandlerBuilder useCollisionAvoidance()

useExponentialBackOff

public DefaultErrorHandlerBuilder useExponentialBackOff()

retriesExhaustedLogLevel

public DefaultErrorHandlerBuilder retriesExhaustedLogLevel(LoggingLevel retriesExhaustedLogLevel)

retryAttemptedLogLevel

public DefaultErrorHandlerBuilder retryAttemptedLogLevel(LoggingLevel retryAttemptedLogLevel)

logStackTrace

public DefaultErrorHandlerBuilder logStackTrace(boolean logStackTrace)

logRetryStackTrace

public DefaultErrorHandlerBuilder logRetryStackTrace(boolean logRetryStackTrace)

logHandled

public DefaultErrorHandlerBuilder logHandled(boolean logHandled)

logExhausted

public DefaultErrorHandlerBuilder logExhausted(boolean logExhausted)

asyncDelayedRedelivery

public DefaultErrorHandlerBuilder asyncDelayedRedelivery()
Will allow asynchronous delayed redeliveries.

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

handled

@Deprecated
public DefaultErrorHandlerBuilder handled(boolean handled)
Deprecated. 

Sets whether the exchange should be marked as handled or not.

Parameters:
handled - handled or not
Returns:
the builder

handled

@Deprecated
public DefaultErrorHandlerBuilder handled(Predicate handled)
Deprecated. 

Sets whether the exchange should be marked as handled or not.

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

handled

@Deprecated
public DefaultErrorHandlerBuilder handled(Expression handled)
Deprecated. 

Sets whether the exchange should be marked as handled or not.

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

logger

public DefaultErrorHandlerBuilder logger(CamelLogger logger)
Sets the logger used for caught exceptions

Parameters:
logger - the logger
Returns:
the builder

loggingLevel

public DefaultErrorHandlerBuilder loggingLevel(LoggingLevel level)
Sets the logging level of exceptions caught

Parameters:
level - the logging level
Returns:
the builder

log

public DefaultErrorHandlerBuilder log(org.slf4j.Logger log)
Sets the log used for caught exceptions

Parameters:
log - the logger
Returns:
the builder

log

public DefaultErrorHandlerBuilder log(String log)
Sets the log used for caught exceptions

Parameters:
log - the log name
Returns:
the builder

log

public DefaultErrorHandlerBuilder log(Class<?> log)
Sets the log used for caught exceptions

Parameters:
log - the log class
Returns:
the builder

exceptionPolicyStrategy

public DefaultErrorHandlerBuilder exceptionPolicyStrategy(ExceptionPolicyStrategy exceptionPolicyStrategy)
Sets the exception policy to use

Overrides:
exceptionPolicyStrategy in class ErrorHandlerBuilderSupport
Returns:
the builder

onRedelivery

public DefaultErrorHandlerBuilder 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.

Parameters:
processor - the processor
Returns:
the builder

retryWhile

public DefaultErrorHandlerBuilder 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

useOriginalMessage

public DefaultErrorHandlerBuilder 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 message we use the original IN message instead. This allows you to store the original input in the dead letter queue instead of the inprogress snapshot of the IN message. 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 message 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

getFailureProcessor

public Processor getFailureProcessor()

setFailureProcessor

public void setFailureProcessor(Processor failureProcessor)

getRedeliveryPolicy

public RedeliveryPolicy getRedeliveryPolicy()

setRedeliveryPolicy

public void setRedeliveryPolicy(RedeliveryPolicy redeliveryPolicy)
Sets the redelivery policy


getLogger

public CamelLogger getLogger()

setLogger

public void setLogger(CamelLogger logger)

getExceptionPolicyStrategy

public ExceptionPolicyStrategy getExceptionPolicyStrategy()
Sets the exception policy strategy to use for resolving the OnExceptionDefinition to use for a given thrown exception

Specified by:
getExceptionPolicyStrategy in interface ErrorHandlerBuilder
Overrides:
getExceptionPolicyStrategy in class ErrorHandlerBuilderSupport

setExceptionPolicyStrategy

public void setExceptionPolicyStrategy(ExceptionPolicyStrategy exceptionPolicyStrategy)
Description copied from interface: ErrorHandlerBuilder
Sets the exception policy strategy to use for resolving the OnExceptionDefinition to use for a given thrown exception

Specified by:
setExceptionPolicyStrategy in interface ErrorHandlerBuilder
Overrides:
setExceptionPolicyStrategy in class ErrorHandlerBuilderSupport
Parameters:
exceptionPolicyStrategy - the exception policy strategy

getOnRedelivery

public Processor getOnRedelivery()

setOnRedelivery

public void setOnRedelivery(Processor onRedelivery)

getRetryWhilePolicy

public Predicate getRetryWhilePolicy(CamelContext context)

getRetryWhile

public Predicate getRetryWhile()

setRetryWhile

public void setRetryWhile(Predicate retryWhile)

getRetryWhileRef

public String getRetryWhileRef()

setRetryWhileRef

public void setRetryWhileRef(String retryWhileRef)

getHandledPolicy

@Deprecated
public Predicate getHandledPolicy()
Deprecated. 


setHandledPolicy

@Deprecated
public void setHandledPolicy(Predicate handled)
Deprecated. 


setHandled

@Deprecated
public void setHandled(boolean handled)
Deprecated. 

Sets the handled using a boolean and thus easier to use for Spring XML configuration as well


getDeadLetterUri

public String getDeadLetterUri()

setDeadLetterUri

public void setDeadLetterUri(String deadLetterUri)

getDeadLetter

public Endpoint getDeadLetter()

setDeadLetter

public void setDeadLetter(Endpoint deadLetter)

isUseOriginalMessage

public boolean isUseOriginalMessage()

setUseOriginalMessage

public void setUseOriginalMessage(boolean useOriginalMessage)

isAsyncDelayedRedelivery

public boolean isAsyncDelayedRedelivery()

setAsyncDelayedRedelivery

public void setAsyncDelayedRedelivery(boolean asyncDelayedRedelivery)

createHandledPolicy

protected Predicate createHandledPolicy()

createRedeliveryPolicy

protected RedeliveryPolicy createRedeliveryPolicy()

createLogger

protected CamelLogger createLogger()

toString

public String toString()
Overrides:
toString in class Object


Apache CAMEL