首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在Mule中限制Mule消息

在Mule中限制Mule消息
EN

Stack Overflow用户
提问于 2016-03-01 23:46:09
回答 4查看 264关注 0票数 0

我在Mule中有一个轮询过程,它每30秒查询一次MySQL数据库,并向收件人发送一封电子邮件。无论轮询周期是30秒还是15秒,我如何限制只发送1封电子邮件?如果可以的话,我也可以打开mysql数据库中的一个计数器。

谢谢。

EN

回答 4

Stack Overflow用户

发布于 2016-03-02 06:30:09

编写一个条件,该条件仅在emailSentFlag ==为false时发送电子邮件。

使用choice router创建条件,使用objectstore保存emailSentFlag值。

代码语言:javascript
复制
<flow...>
        ....
        <objectstore:retrieve config-ref="ObjectStore__Configuration" key="emailSentFlag" defaultValue-ref="#[false]" targetProperty="flowVars.emailSentFlag" doc:name="retrieve emailSentFlag"/>
        <choice doc:name="IsEmailSent?">
            <when expression="#[flowVars.emailSentFlag == true]">
                <logger level="INFO" doc:name="Log Email Already Sent"/>
            </when>
            <otherwise>
                <smtp:outbound-endpoint host="" user="" password="" to="" from="" subject="test" cc="" bcc="" replyTo="" responseTimeout="10000" ref="Gmail" doc:name="SMTP" connector-ref="Gmail"/>
                <objectstore:store config-ref="ObjectStore__Configuration" key="emailSentFlag" value-ref="#[true]" doc:name="store emailSentFlag"/>
            </otherwise>
        </choice>
    </flow>

另外,研究一下objectstore的TTL和持久性特性,它对您可能会很有用。

干杯

票数 1
EN

Stack Overflow用户

发布于 2016-05-07 13:38:22

在将“数据”发送到jms之前,您可以将队列(Jms)用于您的用例,这会增加延迟。你可以这样做

代码语言:javascript
复制
  <message-properties-transformer overwrite="true" doc:name="Add DELAY in sending the Response to Queue">
     <add-message-property key="Content_Type" value="application/json"/>
     <add-message-property key="AMQ_SCHEDULED_DELAY" value="${aupost.retry.timeout}"/>
 </message-properties-transformer>

然后添加jms消费者来消费消息,并相应地发送电子邮件。

票数 1
EN

Stack Overflow用户

发布于 2016-03-02 01:04:47

你有没有可以展示的样本流程?您可能能够使用集合/消息聚合器,但首先查看流将有助于您提出建议。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/35727255

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档