org.apache.camel.processor
Class RedeliveryErrorHandler

java.lang.Object
  extended by org.apache.camel.impl.ServiceSupport
      extended by org.apache.camel.processor.ErrorHandlerSupport
          extended by org.apache.camel.processor.RedeliveryErrorHandler
All Implemented Interfaces:
Processor, ErrorHandler, Service
Direct Known Subclasses:
DeadLetterChannel, DefaultErrorHandler

public abstract class RedeliveryErrorHandler
extends ErrorHandlerSupport
implements Processor

Base redeliverable error handler that also suppors a final dead letter queue in case all redelivery attempts fail.

This implementation should contain all the error handling logic and the sub classes should only configure it according to what they support.

Version:
$Revision: 792966 $

Nested Class Summary
protected  class RedeliveryErrorHandler.RedeliveryData
           
 
Field Summary
protected  Processor deadLetter
           
protected  String deadLetterUri
           
protected  Predicate handledPolicy
           
protected  Logger logger
           
protected  Processor output
           
protected  RedeliveryPolicy redeliveryPolicy
           
protected  Processor redeliveryProcessor
           
protected  boolean useOriginalMessagePolicy
           
 
Fields inherited from class org.apache.camel.processor.ErrorHandlerSupport
log
 
Constructor Summary
RedeliveryErrorHandler(Processor output, Logger logger, Processor redeliveryProcessor, RedeliveryPolicy redeliveryPolicy, Predicate handledPolicy, Processor deadLetter, String deadLetterUri, boolean useOriginalMessagePolicy)
           
 
Method Summary
protected  void deliverToFailureProcessor(Processor processor, Exchange exchange, RedeliveryErrorHandler.RedeliveryData data)
          All redelivery attempts failed so move the exchange to the dead letter queue
protected  void deliverToRedeliveryProcessor(Exchange exchange, RedeliveryErrorHandler.RedeliveryData data)
          Gives an optional configure redelivery processor a chance to process before the Exchange will be redelivered.
protected  void doStart()
           
protected  void doStop()
           
 Processor getDeadLetter()
          Returns the dead letter that message exchanges will be sent to if the redelivery attempts fail
 Logger getLogger()
           
 Processor getOutput()
          Returns the output processor
 RedeliveryPolicy getRedeliveryPolicy()
           
protected  void handleException(Exchange exchange, RedeliveryErrorHandler.RedeliveryData data)
           
protected  boolean isDone(Exchange exchange)
          Strategy to determine if the exchange is done so we can continue
protected  void prepareExchangeAfterFailure(Exchange exchange, RedeliveryErrorHandler.RedeliveryData data)
           
protected  void prepareExchangeForRedelivery(Exchange exchange)
           
 void process(Exchange exchange)
          Processes the message exchange
protected  void processErrorHandler(Exchange exchange, RedeliveryErrorHandler.RedeliveryData data)
          Processes the exchange decorated with this dead letter channel.
protected  void processExchange(Exchange exchange)
          Strategy to process the given exchange to the destinated output.
protected  boolean shouldHandleException(Exchange exchange)
          Strategy whether the exchange has an exception that we should try to handle.
 boolean supportTransacted()
          Whether this error handler supports transacted exchanges or not.
 
Methods inherited from class org.apache.camel.processor.ErrorHandlerSupport
addExceptionPolicy, createDefaultExceptionPolicyStrategy, customProcessorForException, getExceptionPolicy, setExceptionPolicy
 
Methods inherited from class org.apache.camel.impl.ServiceSupport
addChildService, getStatus, getVersion, isRunAllowed, isStarted, isStarting, isStopped, isStopping, removeChildService, start, stop
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

deadLetter

protected final Processor deadLetter

deadLetterUri

protected final String deadLetterUri

output

protected final Processor output

redeliveryProcessor

protected final Processor redeliveryProcessor

redeliveryPolicy

protected final RedeliveryPolicy redeliveryPolicy

handledPolicy

protected final Predicate handledPolicy

logger

protected final Logger logger

useOriginalMessagePolicy

protected final boolean useOriginalMessagePolicy
Constructor Detail

RedeliveryErrorHandler

public RedeliveryErrorHandler(Processor output,
                              Logger logger,
                              Processor redeliveryProcessor,
                              RedeliveryPolicy redeliveryPolicy,
                              Predicate handledPolicy,
                              Processor deadLetter,
                              String deadLetterUri,
                              boolean useOriginalMessagePolicy)
Method Detail

supportTransacted

public boolean supportTransacted()
Description copied from class: ErrorHandlerSupport
Whether this error handler supports transacted exchanges or not.

Specified by:
supportTransacted in class ErrorHandlerSupport

process

public void process(Exchange exchange)
             throws Exception
Description copied from interface: Processor
Processes the message exchange

Specified by:
process in interface Processor
Parameters:
exchange - the message exchange
Throws:
Exception - if an internal processing error has occurred.

processErrorHandler

protected void processErrorHandler(Exchange exchange,
                                   RedeliveryErrorHandler.RedeliveryData data)
                            throws Exception
Processes the exchange decorated with this dead letter channel.

Throws:
Exception

shouldHandleException

protected boolean shouldHandleException(Exchange exchange)
Strategy whether the exchange has an exception that we should try to handle.

Standard implementations should just look for an exception.


processExchange

protected void processExchange(Exchange exchange)
                        throws Exception
Strategy to process the given exchange to the destinated output.

This happens when the exchange is processed the first time and also for redeliveries to the same destination.

Throws:
Exception

isDone

protected boolean isDone(Exchange exchange)
                  throws Exception
Strategy to determine if the exchange is done so we can continue

Throws:
Exception

getOutput

public Processor getOutput()
Returns the output processor


getDeadLetter

public Processor getDeadLetter()
Returns the dead letter that message exchanges will be sent to if the redelivery attempts fail


getRedeliveryPolicy

public RedeliveryPolicy getRedeliveryPolicy()

getLogger

public Logger getLogger()

prepareExchangeForRedelivery

protected void prepareExchangeForRedelivery(Exchange exchange)

handleException

protected void handleException(Exchange exchange,
                               RedeliveryErrorHandler.RedeliveryData data)

deliverToRedeliveryProcessor

protected void deliverToRedeliveryProcessor(Exchange exchange,
                                            RedeliveryErrorHandler.RedeliveryData data)
Gives an optional configure redelivery processor a chance to process before the Exchange will be redelivered. This can be used to alter the Exchange.


deliverToFailureProcessor

protected void deliverToFailureProcessor(Processor processor,
                                         Exchange exchange,
                                         RedeliveryErrorHandler.RedeliveryData data)
All redelivery attempts failed so move the exchange to the dead letter queue


prepareExchangeAfterFailure

protected void prepareExchangeAfterFailure(Exchange exchange,
                                           RedeliveryErrorHandler.RedeliveryData data)

doStart

protected void doStart()
                throws Exception
Specified by:
doStart in class ServiceSupport
Throws:
Exception

doStop

protected void doStop()
               throws Exception
Specified by:
doStop in class ServiceSupport
Throws:
Exception


Apache CAMEL