我在我的 Mule 应用程序中使用 JMS 端点和 Apache ActiveMQ(我已经遵循了教程,不确定我是否依赖 JMS 作为端点做正确的事情)
<jms:activemq-connector name="jms-connector" brokerURL="${BrokerURL}" disableTemporaryReplyToDestinations="true" specification="1.1"/>
<jms:endpoint connector-ref="jms-connector" exchange-pattern="one-way" name="UnsortedOrders" queue="UnsortedOrders"/>
<jms:endpoint connector-ref="jms-connector" exchange-pattern="one-way" name="DestinationEMC" queue="DestinationEMC" />
<jms:endpoint connector-ref="jms-connector" exchange-pattern="one-way" name="DestinationOriginal" queue="DestinationOriginal"/>
此时,我需要自动存储(保留在磁盘上)关联的队列,以便电源故障和其他故障不会永久终止未完成的进程,并且一旦 mule 再次启动,该进程就会继续。
我之前使用过带标签的ObjectStore,但我不知道如何将它与JMS端点队列绑定(bind)。这就是我之前使用 ObjectStore 的方式:
<spring:bean id="objectStore" class="org.mule.util.store.QueuePersistenceObjectStore"/>
<until-successful objectStore-ref="objectStore" maxRetries="${MaximumRetry}" secondsBetweenRetries="${RetryInterval}">
<http:outbound-endpoint address="${ECMURL}" exchange-pattern="one-way">
<transformer ref="contentTypeTextXML"/>
</http:outbound-endpoint>
</until-successful>
最佳答案
您无法将对象存储绑定(bind)到 JMS 端点。也就是说 - 如果您不重写 ObjectStore 实现。
但是,您可以使用 JMS 持久性实现相同的目标。您必须使用事务。
<jms:inbound-endpoint queue="Destination.EMC" connector-ref="jms-connector">
<jms:transaction action="ALWAYS_BEGIN"/>
</jms:inbound-endpoint>
<http:outbound-endpoint address="${ECMURL}" exchange-pattern="one-way">
<transformer ref="contentTypeTextXML"/>
</http:outbound-endpoint>
因此,如果您将消息放入队列,它将尝试发布到 HTTP,如果失败,它将回滚到队列并重试。当所有尝试都已完成但调用仍然不成功时,消息将回滚到死信队列,默认情况下为 ActiveMQ.DLQ
。
要控制消息重试的次数以及重试之间的延迟,您可以使用 redelivery policy .
您可以将重新投递政策详细信息添加到代理 URL。即
tcp://localhost:61616?jms.redeliveryPolicy.maximumRedeliveries=${MaximumRetry}&jms.redeliveryPolicy.redeliveryDelay=${RetryIntervalInMilliseconds}
有关如何将 ActiveMQ 重新交付与 Mule ESB 结合使用的详细说明可以在 Mule ESB blog 上找到。 .
关于java - 如何在 Mule ESB 中持久化包含 Java 消息的队列?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28408638/