-1

Im creating a dead letter channel errorhandler like below

errorHandler(deadLetterChannel("direct:myDLC").useOriginalMessage().maximumRedeliveries(1));

from("direct:myDLC")
.bean(MyErrorProcessor.class);

The Bean MyErrorProcessor should be able to handle all types of checked and unchecked exceptions like below..

public void process(Exchange exchange) throws Exception {
    Exception e=(Exception)exchange.getProperty(Exchange.EXCEPTION_CAUGHT, Exception.class);
    e.printStackTrace();
    if(e instanceof MyUncheckedException){
        logger.error("MyUncheckedException: "+((MyException) e).getErrorCode()+" : "+((MyException) e).getErrorDesc());
    }else if(e instanceof MyException){
        logger.error("MyException: "+((MyException) e).getErrorCode()+" : "+((MyException) e).getErrorDesc());
    }
}

But after exception is handled the original message should be redirected to route's endpoint.. how to continue route once exception handled like this??

Balaji Kannan
  • 407
  • 6
  • 24
  • I don't really understand, it should be redirected to route's endpoint? Which endpoint? from("direct:myDLC") .bean(MyErrorProcessor.class) .to(desiredEndpoint); ? – J2B Apr 22 '15 at 11:22
  • Sorry i missed the actual route, from("file:/E:/Target/").routeId("Route1") .setHeader("route1Header").constant("changed") .log(LoggingLevel.DEBUG, "Route1Logger", "Inside Route 1") .throwException(new MyException("E_MYERROR_01")) .to("file:/E:/Target/Done"); once the MyException is handled in deadletterchannel, what should be done to continue the above route.? – Balaji Kannan Apr 23 '15 at 04:23

1 Answers1

1

Using continued() will work, it will ignore the error and continue to process, so then you would probably want to handle the specific Exception

see http://camel.apache.org/exception-clause.html

onException(MyException.class)
    .continued(true)
;

If you would use .useOriginalMessage() on this exception handling, the original message would be the message that is continued.

J2B
  • 1,703
  • 2
  • 16
  • 31