使用CLIENT_ACKNOWLEDGE模式的Mule jms?即使我没有使用它,消息也会自动消耗

时间:2014-08-26 17:39:32

标签: jms mule

我使用CLIENT_ACKNOWLEDGE模式创建了一个简单的mule JMS流程。我对&CLIAND_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>

在我的测试流程中,我还没有确认消息,但它仍然被消耗掉了。如何从客户端或接收方获得确认,我们如何将消息保持在队列中?

<!-------------- 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 个答案:

答案 0 :(得分:3)

您在JMS入站端点中缺少client-ack-transaction元素。

该主题的文档很薄:http://www.mulesoft.org/documentation/display/current/JMS+Transport+Reference#JMSTransportReference-Clientacktransaction

我计划使用此标记向您提供集成测试的链接但找不到:(请参阅:https://github.com/mulesoft/mule/search?utf8=%E2%9C%93&q=client-ack-transaction&type=Code