Pergunta

I have a mule flow that could throw an exception (unable to connect to connector, component throws exception etc). When this happens, the mule flow stops where the exception happenned. I need to catch any exception that the flow throws and send an eMail notification indicating an exception happenned. (especially for flows that would run async like reading from JMS). What element in the flow should I use to catch any exception and send an eMail?

I have tried:

<default-exception-strategy>
        <smtp:outbound-endpoint host="${email.relay.host}"
                    mimeType="text/html" from="${email.support.from" to="${email.support.to}"
                    cc="${email.support.cc}" bcc="${email.support.bcc}" subject="${email.support.subject}">
            </smtp:outbound-endpoint>
    </default-exception-strategy>

but this does not get kicked off at all. I have also tried:

<exception-type-filter expectedType="java.lang.Exception"></exception-type-filter> 

but this seems to work only when the flow throws exceptions( normal flow functioning is changed).

@David Dossot - I added the following snippet:

I added the following snippet :

<catch-exception-strategy>
            <smtp:outbound-endpoint host="${email.relay.host}"
                            mimeType="text/html" from="${email.support.from" to="${email.support.to}"
                            cc="${email.support.cc}" bcc="${email.support.bcc}" subject="${email.support.subject}">
            </smtp:outbound-endpoint>
    </catch-exception-strategy>

but I am getting an erro when starting the mule app:

Root Exception stack trace: org.xml.sax.SAXParseException: cvc-complex-type.2.4.a: Invalid content was found starting with element 'catch-exception-strategy'. One of '{"http://www.mulesoft.org/schema/mule/core":abstract-message-processor, "http://www.mulesoft.org/schema/mule/core":abstract-outbound-endpoint, "http://www.mulesoft.org/schema/mule/core":response, "http://www.mulesoft.org/schema/mule/core":abstract-exception-strategy, "http://www.mulesoft.org/schema/mule/core":abstract-message-info-mapping}' is expected. at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:195) at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:131) at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:384) + 3 more (set debug level logging or '-Dmule.verbose.exceptions=true' for everything)


I am using Mule 3.2.2. Can you please help?

Foi útil?

Solução

On Mule 3.3, I'm typically using catch-exception-strategy for that.

On Mule 3.2 and before, default-exception-strategy is the right choice, but it's possible that some exceptions are not caught properly. This has been overhauled in Mule 3.3. Time to upgrade?

Outras dicas

try using this one. } was missing in from.

<catch-exception-strategy>
<smtp:outbound-endpoint host="${email.relay.host}"
    mimeType="text/html" from="${email.support.from}" to="${email.support.to}" cc="${email.support.cc}" bcc="${email.support.bcc}" subject="${email.support.subject}">
</smtp:outbound-endpoint></catch-exception-strategy>
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top