[ 
https://issues.apache.org/jira/browse/CAMEL-22820?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18050596#comment-18050596
 ] 

Claus Ibsen commented on CAMEL-22820:
-------------------------------------

You need to add the same global route configuration to all the routes - its not 
the same as the regular route where onException is global for all 3 routes.

 

If you add this then it works
{code:java}
from("direct:errorRoute2")
    .routeId("errorRoute2")
    .routeConfigurationId("globalErrorHandling")
    .to("log:error-step-2?showAll=true&multiline=true")
    .to("direct:errorRoute3");

from("direct:errorRoute3")
    .routeId("errorRoute3")
    .routeConfigurationId("globalErrorHandling")
    .to("log:error-step-3?showAll=true&multiline=true");
 {code}
 

Or use the ID * instead of globalErrorHandling then its automatic global
{code:java}
static class routesWithRouteConfiguration extends RouteBuilder {

    @Override
    public void configure() {

        // ----------------------------
        // IMAP route (example)
        // ----------------------------
        from("imaps://outlook.office365.com:993"
                + "?username=RAW([email protected])"
                + "&password=RAW(password123)"
                + "&delay=320000"
                + "&searchTerm.subject=RAW(subject text)"
                + "&bridgeErrorHandler=true")
            .routeId("imapRoute")
            .log("Successfully processed email: ${header.Subject}");

        // ----------------------------
        // Error routes
        // ----------------------------
        from("direct:errorRoute2")
            .routeId("errorRoute2")
            .to("log:error-step-2?showAll=true&multiline=true")
            .to("direct:errorRoute3");

        from("direct:errorRoute3")
            .routeId("errorRoute3")
            .to("log:error-step-3?showAll=true&multiline=true");
    }
}

static class GlobalRouteConfig extends RouteConfigurationBuilder {
    @Override
    public void configuration() throws Exception {
        routeConfiguration("*")
            .onException(Exception.class)
                .handled(true)
                .to("log:error-step-1?showAll=true&multiline=true")
                .to("direct:errorRoute2")
            .end();
    }
}
 {code}

> routeConfiguration onException does not propagate to direct endpoints for 
> consumer-level exceptions
> ---------------------------------------------------------------------------------------------------
>
>                 Key: CAMEL-22820
>                 URL: https://issues.apache.org/jira/browse/CAMEL-22820
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-ftp, camel-mail
>    Affects Versions: 4.10.8, 4.10.9, 4.14.3
>         Environment: Apache Camel *4.10.8,* *4.10.9-SNAPSHOT*
>            Reporter: Bruno Gonçalves
>            Assignee: Claus Ibsen
>            Priority: Minor
>         Attachments: error-handler-reproducer.zip
>
>
> When using {{routeConfiguration}} with {{onException}} in Java DSL, 
> consumer-level exceptions (e.g. IMAP authentication failures) are only 
> {*}partially handled{*}: processors like {{log:}} are executed, but routing 
> to endpoints such as {{direct:}} does not occur.
> The same configuration *works as expected* when {{onException}} is declared 
> directly in a {{{}RouteBuilder{}}}, but {*}fails when moved to 
> {{RouteConfigurationBuilder}}{*}, even though the route references the 
> configuration via {{{}routeConfigurationId{}}}.
> A *reproducer is attached* which contains {*}two cases{*}:
>  # *Using {{routeConfiguration}}*
>  ** {{onException}} is triggered
>  ** {{log:}} endpoint is executed
>  ** {{direct:}} endpoints are *not invoked*
>  # *Using inline {{onException}} in {{RouteBuilder}}*
>  ** Full error handling works as expected
>  ** {{direct:}} routes are invoked correctly
> This behavior has been observed not only with {*}IMAP inbound consumers{*}, 
> but also with {*}FTP inbound consumers{*}, suggesting the issue is *not 
> specific to the Mail component* and may affect other polling or 
> consumer-based endpoints as well.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to