开发者

force order of messages with HornetQ

开发者 https://www.devze.com 2023-01-23 10:58 出处:网络
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'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 pr开发者_JAVA技巧ovider specific.

Any ideas?


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>


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号