1
votes

I've created a simple mule JMS flow with CLIENT_ACKNOWLEDGE mode. My understanding with 'CLIENT_ACKNOWLEDGE' is that we have to explicitly acknowledge the message on receiver or client side, it will not consume from the queue until it would not acknowledge.

 <spring:beans>
        <spring:bean name="connectionFactory"
            class="org.apache.activemq.ActiveMQConnectionFactory">
            <spring:property name="brokerURL" value="tcp://localhost:61616" />
            <spring:property name="redeliveryPolicy">
                <spring:bean class="org.apache.activemq.RedeliveryPolicy">
                    <spring:property name="maximumRedeliveries" value="10" />
                    <spring:property name="initialRedeliveryDelay"
                        value="1000" />
                </spring:bean>
            </spring:property>
        </spring:bean>
        </spring:beans>
    <jms:connector name="Active_MQ3" connectionFactory-ref="connectionFactory" acknowledgementMode="CLIENT_ACKNOWLEDGE" maxRedelivery="10" persistentDelivery="true" specification="1.1" />



<flow name="main1" doc:name="main1">
                <http:inbound-endpoint exchange-pattern="request-response" host="localhost" path="test" port="8099" doc:name="HTTP"/>

                <logger message="starting main flow" level="INFO" doc:name="Logger"/>

                    <jms:outbound-endpoint queue="StudioIN" connector-ref="Active_MQ3" doc:name="JMS">
                         <jms:transaction action="NONE"/>
                    </jms:outbound-endpoint>

            </flow>

          //reading msg from queue, not acknowledging 

            <flow name="worker1" doc:name="worker1">
                <jms:inbound-endpoint queue="StudioIN" connector-ref="Active_MQ1" doc:name="JMS"/>
                <logger message="Consuming payload: #[payload]" level="INFO" doc:name="Logger"/>
            </flow>
        </mule>

In my test flow I haven't acknowledge the message, but it still got consumed. How we can keep message in queue until it get acknowledge from client or receiver side?

<!-------------- Updated flow ------------------------>
<flow name="worker1" doc:name="worker1">
        <jms:inbound-endpoint queue="StudioIN" connector-ref="Active_MQ1" doc:name="JMS">
            <jms:client-ack-transaction action="ALWAYS_BEGIN"/>
        </jms:inbound-endpoint>
        <logger message="Consuming payload: #[payload]" level="INFO" doc:name="Logger"/>
    </flow>
1

1 Answers

3
votes

You're missing a client-ack-transaction element in your JMS inbound endpoint.

The doc is very thin on the subject: http://www.mulesoft.org/documentation/display/current/JMS+Transport+Reference#JMSTransportReference-Clientacktransaction

I was planning to provide you with links to integration tests using this tag but can't find any :( See: https://github.com/mulesoft/mule/search?utf8=%E2%9C%93&q=client-ack-transaction&type=Code