Search code examples
emailexceptionapache-camelimapblueprint-osgi

Handling CAMEL Mail exception


i'm trying to catch Exception in CAMEL, when there is no connection, like this :

<from uri="imap://Uri"/>
   <onException>
    <exception>javax.mail.MessagingException</exception>
            <exception>java.net.NoRouteToHostException</exception>
   <handled>
        <constant>true</constant>
    </handled>
    <transform>
        <simple>Error reported: ${exception.message} - cannot process this message.</simple>
    </transform>
</onException>

But it dont work. I got this error message:

javax.mail.MessagingException: No route to host: connect;
  nested exception is:
    java.net.NoRouteToHostException: No route to host: connect

What's wrong ?


Solution

  • If the error is from the consumer, eg the <from> then you need to bridge the error handler from the consumer.

    See this FAQ:

    The bridge option is also possible for the mail component.