Camel aborting route after exception processor

Viewed 530

I'm having a problem with Camel where, when calling a processor that sets a fault on the exchange, the routing aborts before finishing the route. I have an exception handler configured like this:

onException(Throwable.class) {
  process(new Processor() {
    public void process(Exchange exchange) {
      // do some logging of exception details
    })
    .handled(true)
    .process(new ExceptionProcessor())
    .bean(new QueueBean(), "writeRequest")
    .bean(new QueueBean(), "writeResponse)
    .end();
  });
}

In the ExceptionProcessor class, it looks something like:

public void process(Exchange exchange) {
  Exception ex = exchange.getProperty(Exchange.EXCEPTION_CAUGHT, Exception.class);
  if(ex instanceof MyException) {
    // do some stuff
    exchange.setProperty("errorTransaction", errorMsg);
    exchange.getIn().setBody(response);
    exchange.getIn().setFault(true);
  } else if(ex instanceof SomeOtherException {
    // do some other stuff
    exchange.getIn().setFault(true);
  }
}

The problem is that, if an exception is caught, the QueueBean lines are not called. A SOAP fault is created and sent out, but anything after the process(new ExceptionProcessor) is not called. I admit I am not a Camel expert, so I could be doing something wrong with the way it's all set up.

Interestingly, this used to work. We updated the versions of Camel and Spring to work under JDK 8+ and the behavior changed from Camel 2.13 to Camel 2.20

Now if I comment out the setFault(true) line in the exception processor, it correctly calls the following lines in the route. This sort of makes sense since I'm not actually telling Camel to create a SOAP fault - in fact I'm generating a custom SOAP message to send back instead of a Camel-generated SOAP fault. But, like I said, previously this worked without having to comment out the setFault(true) line.

Further, I have other exceptions in the exception processor that I check for that do send back a SOAP fault, and so (I believe) correctly call setFault(true) on the exchange. These also fail to continue the route and the QueueBean is never created/called.

0 Answers
Related