How to hande exceptions raised in "interceptSendToEndpoint"

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

How to hande exceptions raised in "interceptSendToEndpoint"

chege
Hi,

I have a parent route builder that defines an interceptor and excpetion
handler as follows.

    onException(Exception.class)
                .process(new Processor() {
            @Override
            public void process(Exchange exchange) throws Exception {
                System.out.println("Handling Error");
            }
                });

 interceptSendToEndpoint("velocity://*")
                .setHeader("includeplaintext", () -> "true")
                .setHeader("CamelVelocitySupplementalContext",
method("mailRouter", "x"));

Here is a simplified definition of method "x"

public Map<String, Object> x(@Header("test") String schema) {
throw new RuntimeException("error");
}


Then I have a route that will trigger above interceptor defined as
follows.

        from("activemq://queue:inquiryresponse")
                .routeId("Inquiry Response")
                .log("Sending Inquiry Response ${body}")
                .setHeader("subject", constant("Inquiry Response"))
                .setHeader("to",
simple("${body['fname']}<${body['ccemail']}>"))
                .to("velocity://templates/inquiry_response.html")
                .to("bean:mailRouter?method=routeEmail")
                .log("Sent Inquiry Response ${body}");

The exception handler above is not invoked. What I am missing?

Thanks,
Chege.