public class DefaultErrorHandlerBuilder extends ErrorHandlerBuilderSupport implements DefaultErrorHandlerProperties
Constructor and Description |
---|
DefaultErrorHandlerBuilder() |
Modifier and Type | Method and Description |
---|---|
DefaultErrorHandlerBuilder |
allowRedeliveryWhileStopping(boolean allowRedeliveryWhileStopping)
Controls whether to allow redelivery while stopping/shutting down a route that uses error handling.
|
DefaultErrorHandlerBuilder |
asyncDelayedRedelivery()
Will allow asynchronous delayed redeliveries.
|
DefaultErrorHandlerBuilder |
backOffMultiplier(double backOffMultiplier) |
ErrorHandlerBuilder |
cloneBuilder()
Clones this builder so each
RouteBuilder has its private builder to use, to avoid changes from one
RouteBuilder to influence the others. |
protected void |
cloneBuilder(DefaultErrorHandlerBuilder other) |
DefaultErrorHandlerBuilder |
collisionAvoidancePercent(double collisionAvoidancePercent) |
protected org.apache.camel.spi.CamelLogger |
createLogger() |
protected org.apache.camel.processor.errorhandler.RedeliveryPolicy |
createRedeliveryPolicy() |
DefaultErrorHandlerBuilder |
deadLetterHandleNewException(boolean handleNewException)
Whether the dead letter channel should handle (and ignore) any new exception that may been thrown during sending
the message to the dead letter endpoint.
|
DefaultErrorHandlerBuilder |
delayPattern(String delayPattern) |
DefaultErrorHandlerBuilder |
disableRedelivery() |
DefaultErrorHandlerBuilder |
exchangeFormatterRef(String exchangeFormatterRef) |
DefaultErrorHandlerBuilder |
executorService(ScheduledExecutorService executorService)
Sets the thread pool to be used for redelivery.
|
DefaultErrorHandlerBuilder |
executorServiceRef(String ref)
Sets a reference to a thread pool to be used for redelivery.
|
String |
getDeadLetterUri() |
org.apache.camel.processor.errorhandler.RedeliveryPolicy |
getDefaultRedeliveryPolicy() |
ScheduledExecutorService |
getExecutorService() |
String |
getExecutorServiceRef() |
org.apache.camel.spi.CamelLogger |
getLogger() |
org.apache.camel.Processor |
getOnExceptionOccurred() |
String |
getOnExceptionOccurredRef() |
org.apache.camel.Processor |
getOnPrepareFailure() |
String |
getOnPrepareFailureRef() |
org.apache.camel.Processor |
getOnRedelivery() |
String |
getOnRedeliveryRef() |
org.apache.camel.processor.errorhandler.RedeliveryPolicy |
getRedeliveryPolicy() |
org.apache.camel.Predicate |
getRetryWhile() |
org.apache.camel.Predicate |
getRetryWhilePolicy(org.apache.camel.CamelContext context) |
String |
getRetryWhileRef() |
boolean |
hasLogger() |
boolean |
hasRedeliveryPolicy() |
boolean |
isAsyncDelayedRedelivery() |
boolean |
isDeadLetterHandleNewException() |
boolean |
isUseOriginalBody() |
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 |
logExhaustedMessageBody(boolean logExhaustedMessageBody) |
DefaultErrorHandlerBuilder |
logExhaustedMessageHistory(boolean logExhaustedMessageHistory) |
DefaultErrorHandlerBuilder |
logger(org.apache.camel.spi.CamelLogger logger)
Sets the logger used for caught exceptions
|
DefaultErrorHandlerBuilder |
loggingLevel(org.apache.camel.LoggingLevel level)
Sets the logging level of exceptions caught
|
DefaultErrorHandlerBuilder |
logHandled(boolean logHandled) |
DefaultErrorHandlerBuilder |
logNewException(boolean logNewException) |
DefaultErrorHandlerBuilder |
logRetryAttempted(boolean logRetryAttempted) |
DefaultErrorHandlerBuilder |
logRetryStackTrace(boolean logRetryStackTrace) |
DefaultErrorHandlerBuilder |
logStackTrace(boolean logStackTrace) |
DefaultErrorHandlerBuilder |
maximumRedeliveries(int maximumRedeliveries) |
DefaultErrorHandlerBuilder |
maximumRedeliveryDelay(long maximumRedeliveryDelay) |
DefaultErrorHandlerBuilder |
onExceptionOccurred(org.apache.camel.Processor processor)
Sets a custom
Processor to process the Exchange just after an
exception was thrown. |
DefaultErrorHandlerBuilder |
onExceptionOccurredRef(String onExceptionOccurredRef)
Sets a reference for the processor to use just after an exception was thrown.
|
DefaultErrorHandlerBuilder |
onPrepareFailure(org.apache.camel.Processor processor)
Sets a custom
Processor to prepare the Exchange before handled
by the failure processor / dead letter channel. |
DefaultErrorHandlerBuilder |
onPrepareFailureRef(String onPrepareFailureRef)
Sets a reference for the processor to use before handled by the failure processor.
|
DefaultErrorHandlerBuilder |
onRedelivery(org.apache.camel.Processor processor)
Sets a processor that should be processed before a redelivery attempt.
|
DefaultErrorHandlerBuilder |
onRedeliveryRef(String onRedeliveryRef)
Sets a reference for the processor to use before a redelivery attempt.
|
DefaultErrorHandlerBuilder |
redeliveryDelay(long delay) |
DefaultErrorHandlerBuilder |
retriesExhaustedLogLevel(org.apache.camel.LoggingLevel retriesExhaustedLogLevel) |
DefaultErrorHandlerBuilder |
retryAttemptedLogInterval(int retryAttemptedLogInterval) |
DefaultErrorHandlerBuilder |
retryAttemptedLogLevel(org.apache.camel.LoggingLevel retryAttemptedLogLevel) |
DefaultErrorHandlerBuilder |
retryWhile(org.apache.camel.Expression retryWhile)
Sets the retry while expression.
|
DefaultErrorHandlerBuilder |
retryWhileRef(String retryWhileRef) |
void |
setAsyncDelayedRedelivery(boolean asyncDelayedRedelivery) |
void |
setDeadLetterHandleNewException(boolean deadLetterHandleNewException) |
void |
setDeadLetterUri(String deadLetterUri) |
void |
setExecutorService(ScheduledExecutorService executorService) |
void |
setExecutorServiceRef(String executorServiceRef) |
void |
setLogger(org.apache.camel.spi.CamelLogger logger) |
void |
setOnExceptionOccurred(org.apache.camel.Processor onExceptionOccurred) |
void |
setOnExceptionOccurredRef(String onExceptionOccurredRef) |
void |
setOnPrepareFailure(org.apache.camel.Processor onPrepareFailure) |
void |
setOnPrepareFailureRef(String onPrepareFailureRef) |
void |
setOnRedelivery(org.apache.camel.Processor onRedelivery) |
void |
setOnRedeliveryRef(String onRedeliveryRef) |
void |
setRedeliveryPolicy(org.apache.camel.processor.errorhandler.RedeliveryPolicy redeliveryPolicy)
Sets the redelivery policy
|
void |
setRetryWhile(org.apache.camel.Predicate retryWhile) |
void |
setRetryWhileRef(String retryWhileRef) |
void |
setUseOriginalBody(boolean useOriginalBody) |
void |
setUseOriginalMessage(boolean useOriginalMessage) |
boolean |
supportTransacted()
Whether this error handler supports transacted exchanges.
|
String |
toString() |
DefaultErrorHandlerBuilder |
useCollisionAvoidance() |
DefaultErrorHandlerBuilder |
useExponentialBackOff() |
DefaultErrorHandlerBuilder |
useOriginalBody()
Will use the original input
Message body (original body only) when an
Exchange is moved to the dead letter queue. |
DefaultErrorHandlerBuilder |
useOriginalMessage()
Will use the original input
Message (original body and headers) when an
Exchange is moved to the dead letter queue. |
public boolean supportTransacted()
ErrorHandlerBuilder
supportTransacted
in interface ErrorHandlerBuilder
supportTransacted
in class ErrorHandlerBuilderSupport
public ErrorHandlerBuilder cloneBuilder()
ErrorHandlerBuilder
RouteBuilder
has its private builder to use, to avoid changes from one
RouteBuilder
to influence the others.
This is needed by the current Camel 2.x architecture.cloneBuilder
in interface ErrorHandlerBuilder
ErrorHandlerBuilder
protected void cloneBuilder(DefaultErrorHandlerBuilder other)
public DefaultErrorHandlerBuilder backOffMultiplier(double backOffMultiplier)
public DefaultErrorHandlerBuilder collisionAvoidancePercent(double collisionAvoidancePercent)
public DefaultErrorHandlerBuilder redeliveryDelay(long delay)
public DefaultErrorHandlerBuilder delayPattern(String delayPattern)
public DefaultErrorHandlerBuilder maximumRedeliveries(int maximumRedeliveries)
public DefaultErrorHandlerBuilder disableRedelivery()
public DefaultErrorHandlerBuilder maximumRedeliveryDelay(long maximumRedeliveryDelay)
public DefaultErrorHandlerBuilder useCollisionAvoidance()
public DefaultErrorHandlerBuilder useExponentialBackOff()
public DefaultErrorHandlerBuilder retriesExhaustedLogLevel(org.apache.camel.LoggingLevel retriesExhaustedLogLevel)
public DefaultErrorHandlerBuilder retryAttemptedLogLevel(org.apache.camel.LoggingLevel retryAttemptedLogLevel)
public DefaultErrorHandlerBuilder retryAttemptedLogInterval(int retryAttemptedLogInterval)
public DefaultErrorHandlerBuilder logStackTrace(boolean logStackTrace)
public DefaultErrorHandlerBuilder logRetryStackTrace(boolean logRetryStackTrace)
public DefaultErrorHandlerBuilder logHandled(boolean logHandled)
public DefaultErrorHandlerBuilder logNewException(boolean logNewException)
public DefaultErrorHandlerBuilder logExhausted(boolean logExhausted)
public DefaultErrorHandlerBuilder logRetryAttempted(boolean logRetryAttempted)
public DefaultErrorHandlerBuilder logExhaustedMessageHistory(boolean logExhaustedMessageHistory)
public DefaultErrorHandlerBuilder logExhaustedMessageBody(boolean logExhaustedMessageBody)
public DefaultErrorHandlerBuilder exchangeFormatterRef(String exchangeFormatterRef)
public DefaultErrorHandlerBuilder asyncDelayedRedelivery()
RedeliveryPolicy.setAsyncDelayedRedelivery(boolean)
public DefaultErrorHandlerBuilder allowRedeliveryWhileStopping(boolean allowRedeliveryWhileStopping)
allowRedeliveryWhileStopping
- true to allow redelivery, false to reject redeliveriespublic DefaultErrorHandlerBuilder executorService(ScheduledExecutorService executorService)
executorService
- the scheduled thread pool to usepublic DefaultErrorHandlerBuilder executorServiceRef(String ref)
ref
- reference to a scheduled thread poolpublic DefaultErrorHandlerBuilder logger(org.apache.camel.spi.CamelLogger logger)
logger
- the loggerpublic DefaultErrorHandlerBuilder loggingLevel(org.apache.camel.LoggingLevel level)
level
- the logging levelpublic DefaultErrorHandlerBuilder log(org.slf4j.Logger log)
log
- the loggerpublic DefaultErrorHandlerBuilder log(String log)
log
- the log namepublic DefaultErrorHandlerBuilder log(Class<?> log)
log
- the log classpublic DefaultErrorHandlerBuilder onRedelivery(org.apache.camel.Processor processor)
Exchange
before its being redelivered.processor
- the processorpublic DefaultErrorHandlerBuilder onRedeliveryRef(String onRedeliveryRef)
onRedeliveryRef
- the processor's referenceonRedelivery(Processor)
public DefaultErrorHandlerBuilder retryWhile(org.apache.camel.Expression retryWhile)
retryWhile
- expression that determines when to stop retryingpublic DefaultErrorHandlerBuilder retryWhileRef(String retryWhileRef)
public DefaultErrorHandlerBuilder useOriginalMessage()
Message
(original body and headers) 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. 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.
The difference between useOriginalMessage and useOriginalBody is that the former includes both the original body
and headers, where as the latter only includes the original body. You can use the latter to enrich the message
with custom headers and include the original message body. The former wont let you do this, as its using the
original message body and headers as they are. You cannot enable both useOriginalMessage and useOriginalBody.
Important: The original input means the input message that are bounded by the current
UnitOfWork
. An unit of work typically spans one route, or multiple routes if they
are connected using internal endpoints such as direct or seda. When messages is passed via external endpoints
such as JMS or HTTP then the consumer will create a new unit of work, with the message it received as input as
the original input. Also some EIP patterns such as splitter, multicast, will create a new unit of work boundary
for the messages in their sub-route (eg the splitted message); however these EIPs have an option named
shareUnitOfWork which allows to combine with the parent unit of work in regard to error handling and
therefore use the parent original message.
By default this feature is off.useOriginalBody()
public DefaultErrorHandlerBuilder useOriginalBody()
Message
body (original body only) 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. 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.
The difference between useOriginalMessage and useOriginalBody is that the former includes both the original body
and headers, where as the latter only includes the original body. You can use the latter to enrich the message
with custom headers and include the original message body. The former wont let you do this, as its using the
original message body and headers as they are. You cannot enable both useOriginalMessage and useOriginalBody.
Important: The original input means the input message that are bounded by the current
UnitOfWork
. An unit of work typically spans one route, or multiple routes if they
are connected using internal endpoints such as direct or seda. When messages is passed via external endpoints
such as JMS or HTTP then the consumer will create a new unit of work, with the message it received as input as
the original input. Also some EIP patterns such as splitter, multicast, will create a new unit of work boundary
for the messages in their sub-route (eg the splitted message); however these EIPs have an option named
shareUnitOfWork which allows to combine with the parent unit of work in regard to error handling and
therefore use the parent original message.
By default this feature is off.useOriginalMessage()
public DefaultErrorHandlerBuilder deadLetterHandleNewException(boolean handleNewException)
Exchange
. This can be used
in situations where you use transactions, and want to use Camel's dead letter channel to deal with exceptions
during routing, but if the dead letter channel itself fails because of a new exception being thrown, then by
setting this to false the new exceptions is propagated back and set on the
Exchange
, which allows the transaction to detect the exception, and rollback.handleNewException
- true to handle (and ignore), false to catch and propagated the
exception on the Exchange
public DefaultErrorHandlerBuilder onPrepareFailure(org.apache.camel.Processor processor)
Processor
to prepare the Exchange
before handled
by the failure processor / dead letter channel. This allows for example to enrich the message before sending to a
dead letter queue.processor
- the processorpublic DefaultErrorHandlerBuilder onPrepareFailureRef(String onPrepareFailureRef)
onPrepareFailureRef
- the processor's referenceonPrepareFailure(Processor)
public DefaultErrorHandlerBuilder onExceptionOccurred(org.apache.camel.Processor processor)
Processor
to process the Exchange
just after an
exception was thrown. This allows to execute the processor at the same time the exception was thrown.
Important: Any exception thrown from this processor will be ignored.processor
- the processorpublic DefaultErrorHandlerBuilder onExceptionOccurredRef(String onExceptionOccurredRef)
onExceptionOccurredRef
- the processor's referenceonExceptionOccurred(Processor)
public boolean hasRedeliveryPolicy()
hasRedeliveryPolicy
in interface DefaultErrorHandlerProperties
public org.apache.camel.processor.errorhandler.RedeliveryPolicy getDefaultRedeliveryPolicy()
getDefaultRedeliveryPolicy
in interface DefaultErrorHandlerProperties
public org.apache.camel.processor.errorhandler.RedeliveryPolicy getRedeliveryPolicy()
getRedeliveryPolicy
in interface DefaultErrorHandlerProperties
public void setRedeliveryPolicy(org.apache.camel.processor.errorhandler.RedeliveryPolicy redeliveryPolicy)
setRedeliveryPolicy
in interface DefaultErrorHandlerProperties
public boolean hasLogger()
hasLogger
in interface DefaultErrorHandlerProperties
public org.apache.camel.spi.CamelLogger getLogger()
getLogger
in interface DefaultErrorHandlerProperties
public void setLogger(org.apache.camel.spi.CamelLogger logger)
setLogger
in interface DefaultErrorHandlerProperties
public org.apache.camel.Processor getOnRedelivery()
getOnRedelivery
in interface DefaultErrorHandlerProperties
public void setOnRedelivery(org.apache.camel.Processor onRedelivery)
setOnRedelivery
in interface DefaultErrorHandlerProperties
public String getOnRedeliveryRef()
getOnRedeliveryRef
in interface DefaultErrorHandlerProperties
public void setOnRedeliveryRef(String onRedeliveryRef)
setOnRedeliveryRef
in interface DefaultErrorHandlerProperties
public org.apache.camel.Predicate getRetryWhilePolicy(org.apache.camel.CamelContext context)
public org.apache.camel.Predicate getRetryWhile()
getRetryWhile
in interface DefaultErrorHandlerProperties
public void setRetryWhile(org.apache.camel.Predicate retryWhile)
setRetryWhile
in interface DefaultErrorHandlerProperties
public String getRetryWhileRef()
getRetryWhileRef
in interface DefaultErrorHandlerProperties
public void setRetryWhileRef(String retryWhileRef)
setRetryWhileRef
in interface DefaultErrorHandlerProperties
public String getDeadLetterUri()
getDeadLetterUri
in interface DefaultErrorHandlerProperties
public void setDeadLetterUri(String deadLetterUri)
setDeadLetterUri
in interface DefaultErrorHandlerProperties
public boolean isDeadLetterHandleNewException()
isDeadLetterHandleNewException
in interface DefaultErrorHandlerProperties
public void setDeadLetterHandleNewException(boolean deadLetterHandleNewException)
setDeadLetterHandleNewException
in interface DefaultErrorHandlerProperties
public boolean isUseOriginalMessage()
isUseOriginalMessage
in interface DefaultErrorHandlerProperties
public void setUseOriginalMessage(boolean useOriginalMessage)
setUseOriginalMessage
in interface DefaultErrorHandlerProperties
public boolean isUseOriginalBody()
isUseOriginalBody
in interface DefaultErrorHandlerProperties
public void setUseOriginalBody(boolean useOriginalBody)
setUseOriginalBody
in interface DefaultErrorHandlerProperties
public boolean isAsyncDelayedRedelivery()
isAsyncDelayedRedelivery
in interface DefaultErrorHandlerProperties
public void setAsyncDelayedRedelivery(boolean asyncDelayedRedelivery)
setAsyncDelayedRedelivery
in interface DefaultErrorHandlerProperties
public ScheduledExecutorService getExecutorService()
getExecutorService
in interface DefaultErrorHandlerProperties
public void setExecutorService(ScheduledExecutorService executorService)
setExecutorService
in interface DefaultErrorHandlerProperties
public String getExecutorServiceRef()
getExecutorServiceRef
in interface DefaultErrorHandlerProperties
public void setExecutorServiceRef(String executorServiceRef)
setExecutorServiceRef
in interface DefaultErrorHandlerProperties
public org.apache.camel.Processor getOnPrepareFailure()
getOnPrepareFailure
in interface DefaultErrorHandlerProperties
public void setOnPrepareFailure(org.apache.camel.Processor onPrepareFailure)
setOnPrepareFailure
in interface DefaultErrorHandlerProperties
public String getOnPrepareFailureRef()
getOnPrepareFailureRef
in interface DefaultErrorHandlerProperties
public void setOnPrepareFailureRef(String onPrepareFailureRef)
setOnPrepareFailureRef
in interface DefaultErrorHandlerProperties
public org.apache.camel.Processor getOnExceptionOccurred()
getOnExceptionOccurred
in interface DefaultErrorHandlerProperties
public void setOnExceptionOccurred(org.apache.camel.Processor onExceptionOccurred)
setOnExceptionOccurred
in interface DefaultErrorHandlerProperties
public String getOnExceptionOccurredRef()
getOnExceptionOccurredRef
in interface DefaultErrorHandlerProperties
public void setOnExceptionOccurredRef(String onExceptionOccurredRef)
setOnExceptionOccurredRef
in interface DefaultErrorHandlerProperties
protected org.apache.camel.processor.errorhandler.RedeliveryPolicy createRedeliveryPolicy()
protected org.apache.camel.spi.CamelLogger createLogger()
Apache Camel