mysql - 在 Mule 中限制 Mule 消息

标签 mysql mule esb throttling

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

谢谢。

最佳答案

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

使用选择路由器创建条件,并使用对象存储来保存 emailSentFlag 值。

<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>

还可以探索对象存储的 TTL 和持久性功能,它可能对您有用。

干杯

关于mysql - 在 Mule 中限制 Mule 消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35727255/

相关文章:

javascript - 如何从数据库中获取数据到javascript文件中并将其存储在数组中?

mysql - 选择员 worker 数最多的部门

php - Laravel - 多种关系 Eloquent

variables - 如何检查 Mule MEL 中是否存在 session 变量?

java - 面向消息的中间件 (MoM) 与。企业服务总线 (ESB)

php - MySQL 选择 IF INNER JOIN

mongodb - 禁用身份验证时在 MuleStudio 中配置 MongoDB 连接器 - "failed to connect"错误

java - 如何读取mule esb中的参数

java - Mule:不同组件的接口(interface)绑定(bind),如何避免重复?

esb - 将Mule ESB服务的请求传递给条件路由器