apache-camel

Is there a way to abort the processing of a Routing Slip without throwing an Exception?


I have a routing slip that has a handful of steps. I want to be able to include steps that perform some validation that can short-circuit the routing slip if needed.

I have:

from("direct:Start")
  .setHeader(header("RoutingSlip", config::getRoutingSlip)
  .doTry()
    .routingSlip(header("RoutingSlip"))
  .doEndTry()
    .doCatch(ValidationException.class)
      .log("Validation failed!")
  .end()

Is this the best way to do this?

The fact that there is a stacktrace being logged makes me question if this is the right way to do this.

Thanks.


Solution

  • Could you try to replace your raising exception code by setting the property Exchange.ROUTE_STOP to true
    ie. exchange.setProperty(Exchange.ROUTE_STOP, Boolean.TRUE);