Mule exception strategy does not stop flow from pr

2019-08-05 19:46发布

问题:

I've the following scenario. If for some reason the FTP upload fails (in this case I entered wrong credentials), the catch exception strategy is called correctly, but I still see the message Upload complete. in my log files.

Why does the flow continue its execution after an exception occurs?

<flow name="mainFlow" doc:name="mainFlow">
    <vm:inbound-endpoint path="test" exchange-pattern="one-way" />

    <choice>
        <when expression="#[flowVars.fileToUpload != null]">
            <set-payload value="#[flowVars.fileToUpload]" /> 
            <ftp:outbound-endpoint host="${ftp.host}" port="${ftp.port}" user="${ftp.username}" password="${ftp.password}" path="${ftp.path.input}"  outputPattern="#[flowVars.fileName]" /> 
        </when>
        <otherwise>
            <logger doc:name="Logger"/>
        </otherwise>
    </choice>

    <logger message="Upload complete." level="INFO" />

    <catch-exception-strategy>
        <logger doc:name="Exception occurred"/>
    </catch-exception-strategy>
</flow>

回答1:

Because the incoming MuleEvent is asynchronous. Try setting the processiingStrategy="synchronous" on theflow:

<flow name="mainFlow" doc:name="mainFlow" processingStrategy="synchronous">
    ....
</flow>


标签: ftp mule esb