使用 HornetQ 强制消息顺序

发布于 2024-09-30 13:38:30 字数 200 浏览 0 评论 0原文

我已经设置了一个 jms 服务器,其中 HornetQ 作为 JMS 提供者(队列)。

我有一个应用程序充当生产者,另一个应用程序(不同的计算机)充当消费者。

我知道 JMS 规范不能保证传递的顺序,但我正在寻找一种方法来做到这一点:完全按照消息发送的顺序接收消息,即使它是特定于提供商。

有什么想法吗?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

清风不识月 2024-10-07 13:38:30

显然,这可以通过禁用消费者缓存来实现。这是通过更改 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>

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>
白云不回头 2024-10-07 13:38:30

实际上,JMS 规范的第 4.4.10.2 节(消息发送顺序)对于顺序非常清楚。

如果队列或主题订阅有单个生产者和单个消费者,则即使存在重新传递,也始终保证消息排序。

如果您有多个消费者,则在回滚或关闭消费者的情况下可能会重新交付客户端缓冲,并且可能会无序交付客户端缓冲区。

在 HornetQ 上,您还拥有消息组,它对生成的消息赋予额外的排序约束。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文