不使用 JMS 包装器如何使用 HornetQ 核心 API 模拟 JMS 主题

发布于 2024-10-10 10:41:29 字数 653 浏览 0 评论 0原文

我想使用 HornetQ 核心 API 来翻译 JMS 主题的概念。

我从简短的检查中看到的问题是,主类 JMSServerManagerImpl (来自 hornetq-jms.jar)使用 jndi 来协调它所需的各种协作者。我想避免使用 jndi,因为它不是独立的,并且是一个全局共享对象,这是一个问题,尤其是在 osgi 环境中。一种替代方法是从 JMSServerManagerImpl 开始复制,但这似乎需要大量工作。

我宁愿确认我模拟 hornetq 中如何支持主题的方法是解决此问题的正确方法。如果有人有足够的知识,也许他们可以评论我认为使用核心 API 编写我自己的主题模拟的方法。

假设

  • 如果消息使用者失败(通过回滚),容器将尝试将消息传递给同一主题的另一个不同的使用者。

仿真

  1. 包装为主题添加的每条消息。
  2. 发送者发送带有确认处理程序集的消息。
  3. (1) 的包装器将在真正的侦听器返回后回滚。
  4. 然后,发送者确认发送,

我假设 4 后,消息在发送给所有消息接收者后发送。如果我犯了任何错误或者我的假设是错误的,请评论。我不确定这种关于确认如何工作的假设是否正确,所以任何指针都会很好。

I would like to translate the concept of JMS topics using HornetQ core API.

The problem i see from my brief examination it would appear the main class JMSServerManagerImpl (from hornetq-jms.jar) uses jndi to coordinate the various collaborators it requires. I would like to avoid jndi as it is not self contained and is a globally shared object which is a problem especially in an osgi environment. One alternative is to copy starting at JMSServerManagerImpl but that seems like a lot of work.

I would rather have a confirmation that my approach to emulating how topics are supported in hornetq is the right way to solve this problem. If anyone has sufficient knowledge perhaps they can comment on what i think is the approach to writing my own emulation of topics using the core api.

ASSUMPTION

  • if a message consumer fails (via rollback) the container will try deliverying the message to another different consumer for the same topic.

EMULATION

  1. wrap each message that is added for the topic.
  2. sender sends msg w/ an acknowledgement handler set.
  3. the wrapper for (1) would rollback after the real listener returns.
  4. the sender then acknowledges delivery

I am assuming after 4 the msg is delivered after being given to all msg receivers. If i have made any mistakes or my assumptions are wrong please comment. Im not sure exactly if this assumption of how acknowledgements work is correct so any pointers would be nice.

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

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

发布评论

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

评论(2

木有鱼丸 2024-10-17 10:41:29

如果您想弄清楚如何使用核心 API 向多个消费者发送消息;这是我的建议

  1. 创建队列 1 并绑定到地址 1
  2. 创建队列 2 并绑定到地址 1
  3. 创建队列 N 并绑定到地址 1

  4. 在地址 1 上发送消息

  5. 启动N个消费者,每个消费者监听队列1-N

这样它基本上就像一个主题一样工作。

If you are trying to figure out how to send a message to multiple consumers using the core API; here is what I recommend

  1. Create queue 1 and bind to address1
  2. Create queue 2 and bind to address1
  3. Make queue N and bind to address 1

  4. Send a message on address1

  5. Start N consumers where each consumer listens on queue 1-N

This way it basically works like a topic.

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