org.apache.camel.processor
Class DeadLetterChannel

java.lang.Object
  extended by org.apache.camel.impl.ServiceSupport
      extended by org.apache.camel.processor.ErrorHandlerSupport
          extended by org.apache.camel.processor.DeadLetterChannel
All Implemented Interfaces:
AsyncProcessor, Processor, ErrorHandler, Service

public class DeadLetterChannel
extends ErrorHandlerSupport
implements AsyncProcessor

Implements a Dead Letter Channel after attempting to redeliver the message using the RedeliveryPolicy

Version:
$Revision: 63653 $

Field Summary
static String CAUGHT_EXCEPTION_HEADER
           
static String EXCEPTION_CAUSE_PROPERTY
           
static String REDELIVERED
           
static String REDELIVERY_COUNTER
           
 
Constructor Summary
DeadLetterChannel(Processor output, Processor deadLetter)
           
DeadLetterChannel(Processor output, Processor deadLetter, RedeliveryPolicy redeliveryPolicy, Logger logger, ExceptionPolicyStrategy exceptionPolicyStrategy)
           
 
Method Summary
protected  void asyncProcess(Exchange exchange, AsyncCallback callback, org.apache.camel.processor.DeadLetterChannel.RedeliveryData data)
           
static
<E extends Exchange>
Logger
createDefaultLogger()
           
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  int incrementRedeliveryCounter(Exchange exchange, Throwable e)
          Increments the redelivery counter and adds the redelivered flag if the message has been redelivered
static boolean isFailureHandled(Exchange exchange)
           
 void process(Exchange exchange)
          Processes the message exchange
 boolean process(Exchange exchange, AsyncCallback callback)
          Processes the message exchange.
 boolean process(Exchange exchange, AsyncCallback callback, org.apache.camel.processor.DeadLetterChannel.RedeliveryData data)
           
protected static void restoreExceptionOnExchange(Exchange exchange, Predicate handledPredicate)
           
static void setFailureHandled(Exchange exchange)
           
 void setLogger(Logger logger)
          Sets the logger strategy; which Log to use and which LoggingLevel to use
 void setRedeliveryPolicy(RedeliveryPolicy redeliveryPolicy)
          Sets the redelivery policy
 String toString()
           
 
Methods inherited from class org.apache.camel.processor.ErrorHandlerSupport
addExceptionPolicy, createDefaultExceptionPolicyStrategy, customProcessorForException, getExceptionPolicy, setExceptionPolicy
 
Methods inherited from class org.apache.camel.impl.ServiceSupport
addChildService, getThreadName, getVersion, isRunAllowed, isStarted, isStarting, isStopped, isStopping, nextThreadCounter, removeChildService, start, stop
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

REDELIVERY_COUNTER

public static final String REDELIVERY_COUNTER
See Also:
Constant Field Values

REDELIVERED

public static final String REDELIVERED
See Also:
Constant Field Values

EXCEPTION_CAUSE_PROPERTY

public static final String EXCEPTION_CAUSE_PROPERTY
See Also:
Constant Field Values

CAUGHT_EXCEPTION_HEADER

public static final String CAUGHT_EXCEPTION_HEADER
See Also:
Constant Field Values
Constructor Detail

DeadLetterChannel

public DeadLetterChannel(Processor output,
                         Processor deadLetter)

DeadLetterChannel

public DeadLetterChannel(Processor output,
                         Processor deadLetter,
                         RedeliveryPolicy redeliveryPolicy,
                         Logger logger,
                         ExceptionPolicyStrategy exceptionPolicyStrategy)
Method Detail

createDefaultLogger

public static <E extends Exchange> Logger createDefaultLogger()

toString

public String toString()
Overrides:
toString in class Object

process

public boolean process(Exchange exchange,
                       AsyncCallback callback)
Description copied from interface: AsyncProcessor
Processes the message exchange. Similar to Processor.process(org.apache.camel.Exchange), but the caller supports having the exchange asynchronously processed.

Specified by:
process in interface AsyncProcessor
Parameters:
exchange - the Exchange to process
callback - the AsyncCallback will be invoked when the processing of the exchange is completed. If the exchange is completed synchronously, then the callback is also invoked synchronously. The callback should therefore be careful of starting recursive loop.
Returns:
true if the processing was completed synchronously.

process

public boolean process(Exchange exchange,
                       AsyncCallback callback,
                       org.apache.camel.processor.DeadLetterChannel.RedeliveryData data)

asyncProcess

protected void asyncProcess(Exchange exchange,
                            AsyncCallback callback,
                            org.apache.camel.processor.DeadLetterChannel.RedeliveryData data)

isFailureHandled

public static boolean isFailureHandled(Exchange exchange)

setFailureHandled

public static void setFailureHandled(Exchange exchange)

restoreExceptionOnExchange

protected static void restoreExceptionOnExchange(Exchange exchange,
                                                 Predicate handledPredicate)

process

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

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

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()

setRedeliveryPolicy

public void setRedeliveryPolicy(RedeliveryPolicy redeliveryPolicy)
Sets the redelivery policy


getLogger

public Logger getLogger()

setLogger

public void setLogger(Logger logger)
Sets the logger strategy; which Log to use and which LoggingLevel to use


incrementRedeliveryCounter

protected int incrementRedeliveryCounter(Exchange exchange,
                                         Throwable e)
Increments the redelivery counter and adds the redelivered flag if the message has been redelivered


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


Copyright © 2008 IONA Open Source Community. All Rights Reserved.