force order of messages with HornetQ

雨燕双飞 提交于 2019-12-12 10:36:23

问题


I've setup a jms server with HornetQ as a JMS provider (Queue).

I have an application which acts as a producer and another one (different computer) as a consumer.

I understand that the JMS specification doesn't guarantee the order of delivery, but I'm looking for a way to do just that: receive the messages exactly in the order they have been sent, even if it's provider specific.

Any ideas?


回答1:


Apparently this can be achieved by disabling the consumer cache. This is done by changing the hornetq-jms.xml:

   <connection-factory name="ConnectionFactory">
      <connectors>
         <connector-ref connector-name="netty-connector"/>
      </connectors>
      <entries>
         <entry name="ConnectionFactory"/>
      </entries>

      <consumer-window-size>0</consumer-window-size> <!-- add this line -->
   </connection-factory>



回答2:


Actually section 4.4.10.2 (Order of Message Sends) of the JMS specification is pretty clear about ordering.

If you have a single producer, and single consumer to a queue or topic subscription, message ordering is always guaranteed even in the presence of redeliveries.

If you have multiple consumers, the client buffering may be redelivered in case of rollbacks or closing your consumer, and the client buffer may be delivered out of ordering.

On HornetQ you also have the message group which entitles extra ordering constraints to the produced messages.



来源:https://stackoverflow.com/questions/4085270/force-order-of-messages-with-hornetq

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!