我在Mule中有一个轮询过程,它每30秒查询一次MySQL数据库,并向收件人发送一封电子邮件。无论轮询周期是30秒还是15秒,我如何限制只发送1封电子邮件?如果可以的话,我也可以打开mysql数据库中的一个计数器。
谢谢。
发布于 2016-03-02 06:30:09
编写一个条件,该条件仅在emailSentFlag ==为false时发送电子邮件。
使用choice router创建条件,使用objectstore保存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>另外,研究一下objectstore的TTL和持久性特性,它对您可能会很有用。
干杯
发布于 2016-05-07 13:38:22
在将“数据”发送到jms之前,您可以将队列(Jms)用于您的用例,这会增加延迟。你可以这样做
<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消费者来消费消息,并相应地发送电子邮件。
发布于 2016-03-02 01:04:47
你有没有可以展示的样本流程?您可能能够使用集合/消息聚合器,但首先查看流将有助于您提出建议。
https://stackoverflow.com/questions/35727255
复制相似问题