简体   繁体   中英

How to persist a queue which contains Java Message in Mule ESB?

I am using JMS endpoints and Apache ActiveMQ in my Mule application (I have followed a tutorial and not sure if i am doing the right thing relying on JMS as endpoints)

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

At this point i need to auto-store (persist on disk) the queues associated with so that power failure and other failures wont kill the unfinished processes for eternity, and the process continues as soon as mule is up again.

I have used ObjectStore with tag before, but i don't know how to bind it with JMS endpoints queue. this is how i have used ObjectStore before :

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

You can't bind an object store to a JMS endpoint. That is - if you don't override the ObjectStore implementation.

You can, however, achieve the same thing using JMS persistence. You have to use transactions.

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

So, if you put a message onto the queue, it will try to post to HTTP and if it fails, it will roll back to the queue and try again. When all attempts has been made and the call is still not successful, the message is rolled back to a dead letter queue, ActiveMQ.DLQ by default.

To control how many times the message will be retried and the delay between retries, you can use a redelivery policy .

You can add redelivery policy details to the broker url. Ie

tcp://localhost:61616?jms.redeliveryPolicy.maximumRedeliveries=${MaximumRetry}&jms.redeliveryPolicy.redeliveryDelay=${RetryIntervalInMilliseconds}

A good explanation of how ActiveMQ redelivery can be used with Mule ESB can be found on the Mule ESB blog .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM