ule流执行意外地因SMTP发送中的错误而分裂

ule流执行意外地因SMTP发送中的错误而分裂

本文介绍了ule流执行意外地因SMTP发送中的错误而分裂的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从SMTP端点捕获错误(例如,如果配置错误或服务器关闭),并且在发生这种情况时,请阻止邮件沿正常路径前进,而是进入异常流程.异常处理程序起作用,消息被路由到异常流中.出乎意料的是,该消息是重复的,并且也将继续进行正常"流程.我希望它只会朝一个方向发展:如果电子邮件发送成功,则进入普通端点,如果发送失败,则进入异常端点.

I would like to catch errors from SMTP endpoint (for example in case it's misconfigured or the server is down) and when this happens, prevent messages from proceeding the normal path and rather go into an exception flow. An exception handler works and messages are routed into an exception flow. What is unexpected is that the message is duplicated and also proceeds with the "normal" flow as well. I would expect it to go only in one direction: if an email was sent successfully go into a normal endpoint, if sendout failed go into an exception endpoint.

在下面提供的示例中,smtp失败,并显示UnknownHostException,并且消息进入failureEndpoint,但是由于某种原因,该消息也以outboundEndpoint结尾:

In the provided example below, smtp is failing with UnknownHostException and the message goes into failureEndpoint but the message for some reason also ends up in the outboundEndpoint:

<mule><!-- namespaces omitted for readability -->
    <flow name="sample-flowFlow1" doc:name="sample-flowFlow1">
        <inbound-endpoint ref="inboundEndpoint" doc:name="AMQP Consumer"/>
        <smtp:outbound-endpoint host="foobaz" to="[email protected]" from="[email protected]" subject="test" responseTimeout="10000" doc:name="SMTP"/>
        <outbound-endpoint ref="outboundEndpoint" doc:name="AMQP Publisher"/>
        <exception-strategy ref="FailureNotification" doc:name="Publish failure notification" />
    </flow>

    <catch-exception-strategy name="FailureNotification">
        <flow-ref name="FailureNotificationFlow" doc:name="Flow Reference" />
    </catch-exception-strategy>
    <sub-flow name="FailureNotificationFlow" doc:name="FailureNotificationFlow">
        <outbound-endpoint ref="failureEndpoint" doc:name="Failure Endpoint"/>
    </sub-flow>
</mule>

在提供的示例中,当消息在inboundEndpoint上发布并且SMTP连接器配置错误时,我希望仅在failEndpoint中看到该消息,而不是在outboundEndpoint和failureEndpoint中都看到.我该怎么做?

When a message is published on inboundEndpoint and SMTP connector is misconfigured the way it is done in the provided example, I would like to see the message exclusively in the failureEndpoint, not in both outboundEndpoint and failureEndpoint. How do I accomplish this?

M子版本:3.4.0

Mule version: 3.4.0

推荐答案

在此流程中,您正在使用多个出站.流不等待smtp的响应,而是继续下一个出站.
可以添加条件以在继续出站之前检查smtp是否成功.

In this flow you are using multiple outbounds. The flow doesn't wait for the response of the smtp and still continues with the next out-bound.
A condition can be added to check whether the smtp was successful before proceeding with the out-bound.

修改后的流程如下所示.试试这个.

The modified flow looks like this. Try this.

<flow name="sample-flowFlow1" doc:name="sample-flowFlow1">
    <inbound-endpoint ref="inboundEndpoint" doc:name="AMQP Consumer"/>
    <flow-ref name="mailingFlow" ></flow-ref>
    <choice>
        <when expression="#[flowVars['mailingSuccess'] == 'failure']">
            <logger level="INFO" message="Mailing failed"></logger>
        </when>
        <otherwise>
            <outbound-endpoint ref="outboundEndpoint" doc:name="AMQP Publisher"/>
        </otherwise>
    </choice>
</flow>

<flow name="mailingFlow" processingStrategy="synchronous" >
    <smtp:outbound-endpoint host="foobaz" to="[email protected]" from="[email protected]" subject="test" responseTimeout="10000" doc:name="SMTP"/>
    <catch-exception-strategy name="FailureNotification">
        <set-variable variableName="mailingSuccess" value="failure" ></set-variable>
        <flow-ref name="FailureNotificationFlow" doc:name="Flow Reference" />
    </catch-exception-strategy>
</flow>

<sub-flow name="FailureNotificationFlow" doc:name="FailureNotificationFlow">
    <outbound-endpoint ref="failureEndpoint" doc:name="Failure Endpoint"/>
</sub-flow>

希望这会有所帮助

这篇关于ule流执行意外地因SMTP发送中的错误而分裂的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-06 04:04