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  String executorServiceRef
           
protected  Processor failureProcessor
           
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  CamelLogger createLogger()
           
protected  RedeliveryPolicy createRedeliveryPolicy()
           
 DefaultErrorHandlerBuilder delayPattern(String delayPattern)
           
 DefaultErrorHandlerBuilder disableRedelivery()
           
 DefaultErrorHandlerBuilder executorServiceRef(String ref)
          Sets a reference to a thread pool to be used for redelivery.
 Endpoint getDeadLetter()
           
 String getDeadLetterUri()
           
 String getExecutorServiceRef()
           
 Processor getFailureProcessor()
           
 CamelLogger getLogger()
           
 Processor getOnRedelivery()
           
 RedeliveryPolicy getRedeliveryPolicy()
           
 Predicate getRetryWhile()
           
 Predicate getRetryWhilePolicy(CamelContext context)
           
 String getRetryWhileRef()
           
 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. will be removed in the near future. Use redeliveryDelay(long) instead
 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 setExecutorServiceRef(String executorServiceRef)
           
 void setFailureProcessor(Processor failureProcessor)
           
 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, exceptionPolicyStrategy, getErrorHandlers, getExceptionPolicyStrategy, setErrorHandlers, setExceptionPolicyStrategy
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

logger

protected CamelLogger logger

redeliveryPolicy

protected RedeliveryPolicy redeliveryPolicy

onRedelivery

protected Processor onRedelivery

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

executorServiceRef

protected String executorServiceRef
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. will be removed in the near future. Use redeliveryDelay(long) instead


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)

executorServiceRef

public DefaultErrorHandlerBuilder executorServiceRef(String ref)
Sets a reference to a thread pool to be used for redelivery.

Parameters:
ref - reference to a scheduled thread pool
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

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)

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)

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)

getExecutorServiceRef

public String getExecutorServiceRef()

setExecutorServiceRef

public void setExecutorServiceRef(String executorServiceRef)

createRedeliveryPolicy

protected RedeliveryPolicy createRedeliveryPolicy()

createLogger

protected CamelLogger createLogger()

toString

public String toString()
Overrides:
toString in class Object


Apache CAMEL