【问题标题】:Failover queue should not deliver the messages until the actual queue start delivering the messages在实际队列开始传递消息之前,故障转移队列不应传递消息
【发布时间】:2013-06-10 14:25:29
【问题描述】:

我正在使用 ActiveMQ 实现向队列发送消息。当队列出现问题时,我会使用故障转移机制将所有消息重定向到另一个队列。

但我的要求是,在第一个队列中的消息被消费者消费之前,消费者不应消费故障转移队列消息。

谁能建议我如何实现这个场景?提前致谢。

这是我的 XML 配置:

<bean id="jmsConnectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory">
  <property name="brokerURL" value="tcp://172.16.121.146:61617" />
</bean>
<bean id="cscoDest" class="org.apache.activemq.command.ActiveMQQueue">
  <constructor-arg value="STOCKS.CSCO" />
</bean>
<!--The message listener-->
<bean id="portfolioListener" class="my.test.jms.Listener"></bean>
<!--Spring DMLC-->
<bean id="cscoConsumer"     class="org.springframework.jms.listener.DefaultMessageListenerContainer102">
  <property name="connectionFactory" ref="jmsConnectionFactory" />
  <property name="destination" ref="cscoDest" />
  <property name="messageListener" ref="portfolioListener" />
  <property name="sessionAcknowledgeModeName" value="CLIENT_ACKNOWLEDGE"/>
</bean>
<!--Spring JMS Template-->
<bean id="jmsTemplate" class="org.springframework.jms.core.JmsTemplate">
  <property name="connectionFactory" ref="jmsConnectionFactory" />
</bean>
<bean id="stockPublisher" class="my.test.jms.SpringPublisher">
  <property name="template" ref="jmsTemplate" />
  <property name="destinations">
    <list>
      <ref local="cscoDest" />
    </list>
  </property>
</bean>

【问题讨论】:

    标签: tomcat7 activemq spring-jms


    【解决方案1】:

    如果与当前代理的连接中断,ActiveMQ 故障转移机制可以让客户端故障转移到另一个 ActiveMQ 代理。

    您要求在第一个队列为空之前第二个队列不应传递消息是非常奇怪的。如果有人通过拔掉插头来终止 ActiveMQ 服务器会发生什么?该服务器上可能仍有未处理的消息,但您无法处理它们。

    您想要的是一个共享磁盘区域(某处的网络共享)的master slave setup。然后第二个代理可以在主代理停止工作的地方接手。

    【讨论】:

    • 对于上述要求,我尝试了故障转移机制,有时我无法接收所有消息,有时我也能够接收已经收到的消息。我认为代理卡在某个地方跨度>
    • 已收到消息?您的代码中可能存在一些问题(未发送的确认,因为您执行 CLIENT_ACKNOWLEDGE,您需要 100% 确保您的代码正确处理它)。
    • 如果我使用单个代理,它工作正常,只有当我使用故障转移机制时才会出现上述情况
    猜你喜欢
    • 2013-08-24
    • 1970-01-01
    • 2017-08-27
    • 1970-01-01
    • 1970-01-01
    • 2012-03-02
    • 2014-12-12
    • 2010-12-05
    • 1970-01-01
    相关资源
    最近更新 更多