如何在ActiveMQ中保留订单? [英] How is ordering preserved in ActiveMQ?

查看:128
本文介绍了如何在ActiveMQ中保留订单?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经设置了一个应用程序来监听ActiveMQ主题.这是我配置它的方式:

I have set up an application to listen to an ActiveMQ topic. Here's the way I have configured it:

<jms:listener-container connection-factory="jmsFactory"
    container-type="default" destination-type="durableTopic" client-id="CMY-LISTENER"
    acknowledge="transacted">
    <jms:listener destination="CMY.UPDATES"
        ref="continuingStudiesCourseUpdateListener" subscription="CMY-LISTENER" />
</jms:listener-container>


<bean id="jmsFactoryDelegate" class="org.apache.activemq.ActiveMQConnectionFactory">
    <property name="brokerURL" value="${jmsFactory.brokerURL}" />
    <property name="redeliveryPolicy">
        <bean class="org.apache.activemq.RedeliveryPolicy">
            <property name="maximumRedeliveries" value="10" />
            <property name="initialRedeliveryDelay" value="60000" />
            <property name="redeliveryDelay" value="60000" />
            <property name="useExponentialBackOff" value="true" />
            <property name="backOffMultiplier" value="2" />
        </bean>
    </property>
</bean>

我的问题是:

我在主题中添加了10条消息.

I put 10 messages into the topic.

如果读取了第一条消息,并且应用程序无法处理任务,则会回滚该消息.

If the first message is read, and the application fails to process the task, it rolls back the message.

1分钟后,它重试以读取第一条消息并进行处理.它失败并回滚.

1 minute later, it retries to read the first message and process it. It fails and rolls back.

2分钟后,它重试并回滚.

2 minutes later, it retries, and rolls back.

4分钟后...等等

它卡在第一条消息上,而接下来的9条消息直到处理第一条消息时才被读取.

It gets stuck on the first message and the next 9 messages don't get read until the first one is dealt with.

这是一个主题应该起作用的方式吗?有没有一种方法可以让我在我的第9条消息等待重试的同时读取其他9条消息?

Is this the way a topic is supposed to work? Is there a way that I can have my 9 other messages read while the first one is waiting to be re-tried?

推荐答案

它的工作原理与预期的一样,这就是事务性消息处理的本质.在第一个消息完成或根据给定的重新交付策略中的规则被丢弃之前,您无法处理其他消息.

Its working just like its supposed to, that's the nature of transactional message processing. You can't process the other messages until the first one completes or is discarded based on the rules in your given redelivery policy.

可能想阅读JMS教程这里:

Might want to read though the JMS tutorial here:

这篇关于如何在ActiveMQ中保留订单?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆