001/*
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements.  See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License.  You may obtain a copy of the License at
008 *
009 *      http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017package org.apache.camel.builder;
018
019import java.util.concurrent.ScheduledExecutorService;
020
021import org.apache.camel.CamelContext;
022import org.apache.camel.Endpoint;
023import org.apache.camel.Expression;
024import org.apache.camel.LoggingLevel;
025import org.apache.camel.Predicate;
026import org.apache.camel.Processor;
027import org.apache.camel.processor.errorhandler.DefaultErrorHandler;
028import org.apache.camel.processor.errorhandler.RedeliveryPolicy;
029import org.apache.camel.spi.CamelLogger;
030import org.apache.camel.spi.Language;
031import org.apache.camel.support.ExpressionToPredicateAdapter;
032import org.slf4j.LoggerFactory;
033
034/**
035 * The default error handler builder.
036 */
037public class DefaultErrorHandlerBuilder extends ErrorHandlerBuilderSupport {
038
039    protected CamelLogger logger;
040    protected RedeliveryPolicy redeliveryPolicy;
041    protected Processor onRedelivery;
042    protected String onRedeliveryRef;
043    protected Predicate retryWhile;
044    protected String retryWhileRef;
045    protected Processor failureProcessor;
046    protected String failureProcessorRef;
047    protected Endpoint deadLetter;
048    protected String deadLetterUri;
049    protected boolean deadLetterHandleNewException = true;
050    protected boolean useOriginalMessage;
051    protected boolean useOriginalBody;
052    protected boolean asyncDelayedRedelivery;
053    protected ScheduledExecutorService executorService;
054    protected String executorServiceRef;
055    protected Processor onPrepareFailure;
056    protected String onPrepareFailureRef;
057    protected Processor onExceptionOccurred;
058    protected String onExceptionOccurredRef;
059
060    public DefaultErrorHandlerBuilder() {
061    }
062
063    @Override
064    public boolean supportTransacted() {
065        return false;
066    }
067
068    @Override
069    public ErrorHandlerBuilder cloneBuilder() {
070        DefaultErrorHandlerBuilder answer = new DefaultErrorHandlerBuilder();
071        cloneBuilder(answer);
072        return answer;
073    }
074
075    protected void cloneBuilder(DefaultErrorHandlerBuilder other) {
076        super.cloneBuilder(other);
077
078        other.logger = logger;
079        if (redeliveryPolicy != null) {
080            other.redeliveryPolicy = redeliveryPolicy.copy();
081        }
082        other.setOnRedelivery(onRedelivery);
083        other.setOnRedeliveryRef(onRedeliveryRef);
084        other.setRetryWhile(retryWhile);
085        other.setRetryWhileRef(retryWhileRef);
086        other.setFailureProcessor(failureProcessor);
087        other.setFailureProcessorRef(failureProcessorRef);
088        if (deadLetter != null) {
089            other.setDeadLetter(deadLetter);
090        }
091        other.setDeadLetterUri(deadLetterUri);
092        other.setOnPrepareFailure(onPrepareFailure);
093        other.setOnPrepareFailureRef(onPrepareFailureRef);
094        other.setOnExceptionOccurred(onExceptionOccurred);
095        other.setOnExceptionOccurredRef(onExceptionOccurredRef);
096        other.setDeadLetterHandleNewException(deadLetterHandleNewException);
097        other.setUseOriginalMessage(useOriginalMessage);
098        other.setUseOriginalBody(useOriginalBody);
099        other.setAsyncDelayedRedelivery(asyncDelayedRedelivery);
100        other.setExecutorServiceRef(executorServiceRef);
101    }
102
103    // Builder methods
104    // -------------------------------------------------------------------------
105    public DefaultErrorHandlerBuilder backOffMultiplier(double backOffMultiplier) {
106        getRedeliveryPolicy().backOffMultiplier(backOffMultiplier);
107        return this;
108    }
109
110    public DefaultErrorHandlerBuilder collisionAvoidancePercent(double collisionAvoidancePercent) {
111        getRedeliveryPolicy().collisionAvoidancePercent(collisionAvoidancePercent);
112        return this;
113    }
114
115    public DefaultErrorHandlerBuilder redeliveryDelay(long delay) {
116        getRedeliveryPolicy().redeliveryDelay(delay);
117        return this;
118    }
119
120    public DefaultErrorHandlerBuilder delayPattern(String delayPattern) {
121        getRedeliveryPolicy().delayPattern(delayPattern);
122        return this;
123    }
124
125    public DefaultErrorHandlerBuilder maximumRedeliveries(int maximumRedeliveries) {
126        getRedeliveryPolicy().maximumRedeliveries(maximumRedeliveries);
127        return this;
128    }
129
130    public DefaultErrorHandlerBuilder disableRedelivery() {
131        getRedeliveryPolicy().maximumRedeliveries(0);
132        return this;
133    }
134
135    public DefaultErrorHandlerBuilder maximumRedeliveryDelay(long maximumRedeliveryDelay) {
136        getRedeliveryPolicy().maximumRedeliveryDelay(maximumRedeliveryDelay);
137        return this;
138    }
139
140    public DefaultErrorHandlerBuilder useCollisionAvoidance() {
141        getRedeliveryPolicy().useCollisionAvoidance();
142        return this;
143    }
144
145    public DefaultErrorHandlerBuilder useExponentialBackOff() {
146        getRedeliveryPolicy().useExponentialBackOff();
147        return this;
148    }
149
150    public DefaultErrorHandlerBuilder retriesExhaustedLogLevel(LoggingLevel retriesExhaustedLogLevel) {
151        getRedeliveryPolicy().setRetriesExhaustedLogLevel(retriesExhaustedLogLevel);
152        return this;
153    }
154
155    public DefaultErrorHandlerBuilder retryAttemptedLogLevel(LoggingLevel retryAttemptedLogLevel) {
156        getRedeliveryPolicy().setRetryAttemptedLogLevel(retryAttemptedLogLevel);
157        return this;
158    }
159
160    public DefaultErrorHandlerBuilder retryAttemptedLogInterval(int retryAttemptedLogInterval) {
161        getRedeliveryPolicy().setRetryAttemptedLogInterval(retryAttemptedLogInterval);
162        return this;
163    }
164
165    public DefaultErrorHandlerBuilder logStackTrace(boolean logStackTrace) {
166        getRedeliveryPolicy().setLogStackTrace(logStackTrace);
167        return this;
168    }
169
170    public DefaultErrorHandlerBuilder logRetryStackTrace(boolean logRetryStackTrace) {
171        getRedeliveryPolicy().setLogRetryStackTrace(logRetryStackTrace);
172        return this;
173    }
174
175    public DefaultErrorHandlerBuilder logHandled(boolean logHandled) {
176        getRedeliveryPolicy().setLogHandled(logHandled);
177        return this;
178    }
179
180    public DefaultErrorHandlerBuilder logNewException(boolean logNewException) {
181        getRedeliveryPolicy().setLogNewException(logNewException);
182        return this;
183    }
184
185    public DefaultErrorHandlerBuilder logExhausted(boolean logExhausted) {
186        getRedeliveryPolicy().setLogExhausted(logExhausted);
187        return this;
188    }
189
190    public DefaultErrorHandlerBuilder logRetryAttempted(boolean logRetryAttempted) {
191        getRedeliveryPolicy().setLogRetryAttempted(logRetryAttempted);
192        return this;
193    }
194
195    public DefaultErrorHandlerBuilder logExhaustedMessageHistory(boolean logExhaustedMessageHistory) {
196        getRedeliveryPolicy().setLogExhaustedMessageHistory(logExhaustedMessageHistory);
197        return this;
198    }
199
200    public DefaultErrorHandlerBuilder logExhaustedMessageBody(boolean logExhaustedMessageBody) {
201        getRedeliveryPolicy().setLogExhaustedMessageBody(logExhaustedMessageBody);
202        return this;
203    }
204
205    public DefaultErrorHandlerBuilder exchangeFormatterRef(String exchangeFormatterRef) {
206        getRedeliveryPolicy().setExchangeFormatterRef(exchangeFormatterRef);
207        return this;
208    }
209
210    /**
211     * Will allow asynchronous delayed redeliveries. The route, in particular
212     * the consumer's component, must support the Asynchronous Routing Engine
213     * (e.g. seda)
214     *
215     * @see RedeliveryPolicy#setAsyncDelayedRedelivery(boolean)
216     * @return the builder
217     */
218    public DefaultErrorHandlerBuilder asyncDelayedRedelivery() {
219        getRedeliveryPolicy().setAsyncDelayedRedelivery(true);
220        return this;
221    }
222
223    /**
224     * Controls whether to allow redelivery while stopping/shutting down a route
225     * that uses error handling.
226     *
227     * @param allowRedeliveryWhileStopping <tt>true</tt> to allow redelivery,
228     *            <tt>false</tt> to reject redeliveries
229     * @return the builder
230     */
231    public DefaultErrorHandlerBuilder allowRedeliveryWhileStopping(boolean allowRedeliveryWhileStopping) {
232        getRedeliveryPolicy().setAllowRedeliveryWhileStopping(allowRedeliveryWhileStopping);
233        return this;
234    }
235
236    /**
237     * Sets the thread pool to be used for redelivery.
238     *
239     * @param executorService the scheduled thread pool to use
240     * @return the builder.
241     */
242    public DefaultErrorHandlerBuilder executorService(ScheduledExecutorService executorService) {
243        setExecutorService(executorService);
244        return this;
245    }
246
247    /**
248     * Sets a reference to a thread pool to be used for redelivery.
249     *
250     * @param ref reference to a scheduled thread pool
251     * @return the builder.
252     */
253    public DefaultErrorHandlerBuilder executorServiceRef(String ref) {
254        setExecutorServiceRef(ref);
255        return this;
256    }
257
258    /**
259     * Sets the logger used for caught exceptions
260     *
261     * @param logger the logger
262     * @return the builder
263     */
264    public DefaultErrorHandlerBuilder logger(CamelLogger logger) {
265        setLogger(logger);
266        return this;
267    }
268
269    /**
270     * Sets the logging level of exceptions caught
271     *
272     * @param level the logging level
273     * @return the builder
274     */
275    public DefaultErrorHandlerBuilder loggingLevel(LoggingLevel level) {
276        getLogger().setLevel(level);
277        return this;
278    }
279
280    /**
281     * Sets the log used for caught exceptions
282     *
283     * @param log the logger
284     * @return the builder
285     */
286    public DefaultErrorHandlerBuilder log(org.slf4j.Logger log) {
287        getLogger().setLog(log);
288        return this;
289    }
290
291    /**
292     * Sets the log used for caught exceptions
293     *
294     * @param log the log name
295     * @return the builder
296     */
297    public DefaultErrorHandlerBuilder log(String log) {
298        return log(LoggerFactory.getLogger(log));
299    }
300
301    /**
302     * Sets the log used for caught exceptions
303     *
304     * @param log the log class
305     * @return the builder
306     */
307    public DefaultErrorHandlerBuilder log(Class<?> log) {
308        return log(LoggerFactory.getLogger(log));
309    }
310
311    /**
312     * Sets a processor that should be processed <b>before</b> a redelivery
313     * attempt.
314     * <p/>
315     * Can be used to change the {@link org.apache.camel.Exchange} <b>before</b>
316     * its being redelivered.
317     *
318     * @param processor the processor
319     * @return the builder
320     */
321    public DefaultErrorHandlerBuilder onRedelivery(Processor processor) {
322        setOnRedelivery(processor);
323        return this;
324    }
325
326    /**
327     * Sets a reference for the processor to use <b>before</b> a redelivery attempt.
328     *
329     * @param onRedeliveryRef the processor's reference
330     * @return the builder
331     * @see #onRedelivery(Processor)
332     */
333    public DefaultErrorHandlerBuilder onRedeliveryRef(String onRedeliveryRef) {
334        setOnRedeliveryRef(onRedeliveryRef);
335        return this;
336    }
337
338    /**
339     * Sets the retry while expression.
340     * <p/>
341     * Will continue retrying until expression evaluates to <tt>false</tt>.
342     *
343     * @param retryWhile expression that determines when to stop retrying
344     * @return the builder
345     */
346    public DefaultErrorHandlerBuilder retryWhile(Expression retryWhile) {
347        setRetryWhile(ExpressionToPredicateAdapter.toPredicate(retryWhile));
348        return this;
349    }
350
351    public DefaultErrorHandlerBuilder retryWhileRef(String retryWhileRef) {
352        setRetryWhileRef(retryWhileRef);
353        return this;
354    }
355
356    /**
357     * Will use the original input {@link org.apache.camel.Message} (original
358     * body and headers) when an {@link org.apache.camel.Exchange} is moved to
359     * the dead letter queue.
360     * <p/>
361     * <b>Notice:</b> this only applies when all redeliveries attempt have
362     * failed and the {@link org.apache.camel.Exchange} is doomed for failure.
363     * <br/>
364     * Instead of using the current inprogress {@link org.apache.camel.Exchange}
365     * IN message we use the original IN message instead. This allows you to
366     * store the original input in the dead letter queue instead of the
367     * inprogress snapshot of the IN message. For instance if you route
368     * transform the IN body during routing and then failed. With the original
369     * exchange store in the dead letter queue it might be easier to manually re
370     * submit the {@link org.apache.camel.Exchange} again as the IN message is
371     * the same as when Camel received it. So you should be able to send the
372     * {@link org.apache.camel.Exchange} to the same input.
373     * <p/>
374     * The difference between useOriginalMessage and useOriginalBody is that the
375     * former includes both the original body and headers, where as the latter
376     * only includes the original body. You can use the latter to enrich the
377     * message with custom headers and include the original message body. The
378     * former wont let you do this, as its using the original message body and
379     * headers as they are. You cannot enable both useOriginalMessage and
380     * useOriginalBody.
381     * <p/>
382     * <b>Important:</b> The original input means the input message that are
383     * bounded by the current {@link org.apache.camel.spi.UnitOfWork}. An unit
384     * of work typically spans one route, or multiple routes if they are
385     * connected using internal endpoints such as direct or seda. When messages
386     * is passed via external endpoints such as JMS or HTTP then the consumer
387     * will create a new unit of work, with the message it received as input as
388     * the original input. Also some EIP patterns such as splitter, multicast,
389     * will create a new unit of work boundary for the messages in their
390     * sub-route (eg the splitted message); however these EIPs have an option
391     * named <tt>shareUnitOfWork</tt> which allows to combine with the parent
392     * unit of work in regard to error handling and therefore use the parent
393     * original message.
394     * <p/>
395     * By default this feature is off.
396     *
397     * @return the builder
398     * @see #useOriginalBody()
399     */
400    public DefaultErrorHandlerBuilder useOriginalMessage() {
401        setUseOriginalMessage(true);
402        return this;
403    }
404
405    /**
406     * Will use the original input {@link org.apache.camel.Message} body
407     * (original body only) when an {@link org.apache.camel.Exchange} is moved
408     * to the dead letter queue.
409     * <p/>
410     * <b>Notice:</b> this only applies when all redeliveries attempt have
411     * failed and the {@link org.apache.camel.Exchange} is doomed for failure.
412     * <br/>
413     * Instead of using the current inprogress {@link org.apache.camel.Exchange}
414     * IN message we use the original IN message instead. This allows you to
415     * store the original input in the dead letter queue instead of the
416     * inprogress snapshot of the IN message. For instance if you route
417     * transform the IN body during routing and then failed. With the original
418     * exchange store in the dead letter queue it might be easier to manually re
419     * submit the {@link org.apache.camel.Exchange} again as the IN message is
420     * the same as when Camel received it. So you should be able to send the
421     * {@link org.apache.camel.Exchange} to the same input.
422     * <p/>
423     * The difference between useOriginalMessage and useOriginalBody is that the
424     * former includes both the original body and headers, where as the latter
425     * only includes the original body. You can use the latter to enrich the
426     * message with custom headers and include the original message body. The
427     * former wont let you do this, as its using the original message body and
428     * headers as they are. You cannot enable both useOriginalMessage and
429     * useOriginalBody.
430     * <p/>
431     * <b>Important:</b> The original input means the input message that are
432     * bounded by the current {@link org.apache.camel.spi.UnitOfWork}. An unit
433     * of work typically spans one route, or multiple routes if they are
434     * connected using internal endpoints such as direct or seda. When messages
435     * is passed via external endpoints such as JMS or HTTP then the consumer
436     * will create a new unit of work, with the message it received as input as
437     * the original input. Also some EIP patterns such as splitter, multicast,
438     * will create a new unit of work boundary for the messages in their
439     * sub-route (eg the splitted message); however these EIPs have an option
440     * named <tt>shareUnitOfWork</tt> which allows to combine with the parent
441     * unit of work in regard to error handling and therefore use the parent
442     * original message.
443     * <p/>
444     * By default this feature is off.
445     *
446     * @return the builder
447     * @see #useOriginalMessage()
448     */
449    public DefaultErrorHandlerBuilder useOriginalBody() {
450        setUseOriginalBody(true);
451        return this;
452    }
453
454    /**
455     * Whether the dead letter channel should handle (and ignore) any new
456     * exception that may been thrown during sending the message to the dead
457     * letter endpoint.
458     * <p/>
459     * The default value is <tt>true</tt> which means any such kind of exception
460     * is handled and ignored. Set this to <tt>false</tt> to let the exception
461     * be propagated back on the {@link org.apache.camel.Exchange}. This can be
462     * used in situations where you use transactions, and want to use Camel's
463     * dead letter channel to deal with exceptions during routing, but if the
464     * dead letter channel itself fails because of a new exception being thrown,
465     * then by setting this to <tt>false</tt> the new exceptions is propagated
466     * back and set on the {@link org.apache.camel.Exchange}, which allows the
467     * transaction to detect the exception, and rollback.
468     *
469     * @param handleNewException <tt>true</tt> to handle (and ignore),
470     *            <tt>false</tt> to catch and propagated the exception on the
471     *            {@link org.apache.camel.Exchange}
472     * @return the builder
473     */
474    public DefaultErrorHandlerBuilder deadLetterHandleNewException(boolean handleNewException) {
475        setDeadLetterHandleNewException(handleNewException);
476        return this;
477    }
478
479    /**
480     * Sets a custom {@link org.apache.camel.Processor} to prepare the
481     * {@link org.apache.camel.Exchange} before handled by the failure processor
482     * / dead letter channel. This allows for example to enrich the message
483     * before sending to a dead letter queue.
484     *
485     * @param processor the processor
486     * @return the builder
487     */
488    public DefaultErrorHandlerBuilder onPrepareFailure(Processor processor) {
489        setOnPrepareFailure(processor);
490        return this;
491    }
492
493    /**
494     * Sets a reference for the processor to use before handled by the failure processor.
495     *
496     * @param onPrepareFailureRef the processor's reference
497     * @return the builder
498     * @see #onPrepareFailure(Processor)
499     */
500    public DefaultErrorHandlerBuilder onPrepareFailureRef(String onPrepareFailureRef) {
501        setOnPrepareFailureRef(onPrepareFailureRef);
502        return this;
503    }
504
505    /**
506     * Sets a custom {@link org.apache.camel.Processor} to process the
507     * {@link org.apache.camel.Exchange} just after an exception was thrown.
508     * This allows to execute the processor at the same time the exception was
509     * thrown.
510     * <p/>
511     * Important: Any exception thrown from this processor will be ignored.
512     *
513     * @param processor the processor
514     * @return the builder
515     */
516    public DefaultErrorHandlerBuilder onExceptionOccurred(Processor processor) {
517        setOnExceptionOccurred(processor);
518        return this;
519    }
520
521    /**
522     * Sets a reference for the processor to use just after an exception was thrown.
523     *
524     * @param onExceptionOccurredRef the processor's reference
525     * @return the builder
526     * @see #onExceptionOccurred(Processor)
527     */
528    public DefaultErrorHandlerBuilder onExceptionOccurredRef(String onExceptionOccurredRef) {
529        setOnExceptionOccurredRef(onExceptionOccurredRef);
530        return this;
531    }
532
533    // Properties
534    // -------------------------------------------------------------------------
535
536    public Processor getFailureProcessor() {
537        return failureProcessor;
538    }
539
540    public void setFailureProcessor(Processor failureProcessor) {
541        this.failureProcessor = failureProcessor;
542    }
543
544    public String getFailureProcessorRef() {
545        return failureProcessorRef;
546    }
547
548    public void setFailureProcessorRef(String failureProcessorRef) {
549        this.failureProcessorRef = failureProcessorRef;
550    }
551
552    public RedeliveryPolicy getRedeliveryPolicy() {
553        if (redeliveryPolicy == null) {
554            redeliveryPolicy = createRedeliveryPolicy();
555        }
556        return redeliveryPolicy;
557    }
558
559    /**
560     * Sets the redelivery policy
561     */
562    public void setRedeliveryPolicy(RedeliveryPolicy redeliveryPolicy) {
563        this.redeliveryPolicy = redeliveryPolicy;
564    }
565
566    public CamelLogger getLogger() {
567        if (logger == null) {
568            logger = createLogger();
569        }
570        return logger;
571    }
572
573    public void setLogger(CamelLogger logger) {
574        this.logger = logger;
575    }
576
577    public Processor getOnRedelivery() {
578        return onRedelivery;
579    }
580
581    public void setOnRedelivery(Processor onRedelivery) {
582        this.onRedelivery = onRedelivery;
583    }
584
585    public String getOnRedeliveryRef() {
586        return onRedeliveryRef;
587    }
588
589    public void setOnRedeliveryRef(String onRedeliveryRef) {
590        this.onRedeliveryRef = onRedeliveryRef;
591    }
592
593    public Predicate getRetryWhilePolicy(CamelContext context) {
594        Predicate answer = getRetryWhile();
595
596        if (getRetryWhileRef() != null) {
597            // its a bean expression
598            Language bean = context.resolveLanguage("bean");
599            answer = bean.createPredicate(getRetryWhileRef());
600        }
601
602        return answer;
603    }
604
605    public Predicate getRetryWhile() {
606        return retryWhile;
607    }
608
609    public void setRetryWhile(Predicate retryWhile) {
610        this.retryWhile = retryWhile;
611    }
612
613    public String getRetryWhileRef() {
614        return retryWhileRef;
615    }
616
617    public void setRetryWhileRef(String retryWhileRef) {
618        this.retryWhileRef = retryWhileRef;
619    }
620
621    public String getDeadLetterUri() {
622        return deadLetterUri;
623    }
624
625    public void setDeadLetterUri(String deadLetterUri) {
626        this.deadLetter = null;
627        this.deadLetterUri = deadLetterUri;
628    }
629
630    public Endpoint getDeadLetter() {
631        return deadLetter;
632    }
633
634    public void setDeadLetter(Endpoint deadLetter) {
635        this.deadLetter = deadLetter;
636        this.deadLetterUri = deadLetter.getEndpointUri();
637    }
638
639    public boolean isDeadLetterHandleNewException() {
640        return deadLetterHandleNewException;
641    }
642
643    public void setDeadLetterHandleNewException(boolean deadLetterHandleNewException) {
644        this.deadLetterHandleNewException = deadLetterHandleNewException;
645    }
646
647    public boolean isUseOriginalMessage() {
648        return useOriginalMessage;
649    }
650
651    public void setUseOriginalMessage(boolean useOriginalMessage) {
652        this.useOriginalMessage = useOriginalMessage;
653    }
654
655    public boolean isUseOriginalBody() {
656        return useOriginalBody;
657    }
658
659    public void setUseOriginalBody(boolean useOriginalBody) {
660        this.useOriginalBody = useOriginalBody;
661    }
662
663    public boolean isAsyncDelayedRedelivery() {
664        return asyncDelayedRedelivery;
665    }
666
667    public void setAsyncDelayedRedelivery(boolean asyncDelayedRedelivery) {
668        this.asyncDelayedRedelivery = asyncDelayedRedelivery;
669    }
670
671    public ScheduledExecutorService getExecutorService() {
672        return executorService;
673    }
674
675    public void setExecutorService(ScheduledExecutorService executorService) {
676        this.executorService = executorService;
677    }
678
679    public String getExecutorServiceRef() {
680        return executorServiceRef;
681    }
682
683    public void setExecutorServiceRef(String executorServiceRef) {
684        this.executorServiceRef = executorServiceRef;
685    }
686
687    public Processor getOnPrepareFailure() {
688        return onPrepareFailure;
689    }
690
691    public void setOnPrepareFailure(Processor onPrepareFailure) {
692        this.onPrepareFailure = onPrepareFailure;
693    }
694
695    public String getOnPrepareFailureRef() {
696        return onPrepareFailureRef;
697    }
698
699    public void setOnPrepareFailureRef(String onPrepareFailureRef) {
700        this.onPrepareFailureRef = onPrepareFailureRef;
701    }
702
703    public Processor getOnExceptionOccurred() {
704        return onExceptionOccurred;
705    }
706
707    public void setOnExceptionOccurred(Processor onExceptionOccurred) {
708        this.onExceptionOccurred = onExceptionOccurred;
709    }
710
711    public String getOnExceptionOccurredRef() {
712        return onExceptionOccurredRef;
713    }
714
715    public void setOnExceptionOccurredRef(String onExceptionOccurredRef) {
716        this.onExceptionOccurredRef = onExceptionOccurredRef;
717    }
718
719    protected RedeliveryPolicy createRedeliveryPolicy() {
720        RedeliveryPolicy policy = new RedeliveryPolicy();
721        policy.disableRedelivery();
722        return policy;
723    }
724
725    protected CamelLogger createLogger() {
726        return new CamelLogger(LoggerFactory.getLogger(DefaultErrorHandler.class), LoggingLevel.ERROR);
727    }
728
729    @Override
730    public String toString() {
731        return "DefaultErrorHandlerBuilder";
732    }
733
734}