消息代理队列和消息类型

发布于 2024-09-01 21:36:55 字数 424 浏览 3 评论 0原文

划分消息队列的标准智慧和考虑因素是什么?

假设消息数量相对较少(< 1000/天),将多种消息类型组合到一个队列中并让消费者使用选择器来过滤它们是否有意义?或者,单个队列应该只处理单个消息类型吗?

我能想到的几个可能的考虑因素:

  • 至少以我对 ActiveMQ 的有限了解,看起来读/写安全性是针对每个队列的。因此,需要不同读/写权限的消息类型将需要不同的队列。
  • 消息选择器似乎需要一个标准标头值(MessageType:AbcMessage)来过滤
  • 队列的爆炸(> 10,> 100,> 1000?)似乎比消息的爆炸对性能的影响更大
  • 单一消息类型每个队列似乎更容易编写客户端代码。只需处理队列中的每条消息即可。如果您想要不同的消息类型,请订阅不同的队列。
  • ???

What's the standard wisdom and considerations for dividing up a message queue?

Assuming relatively small number of messages (< 1000/day), does it make sense to combine multiple message types into a single queue and have consumers use selectors to filter them? Or, should a single queue only handle a single message type?

A couple of possible considerations I can think of:

  • At least in my limited knowledge of ActiveMQ, it looks like Read/Write security is per queue. So message types that need different Read/Write permissions would need different queues.
  • Message Selectors would seem to need a standard header value (MessageType: AbcMessage) to filter on
  • An explosion of queues (> 10, > 100, > 1000?) seems to impact performance more than an explosion of messages
  • A single message type per queue would seem to be easier to write client code for. Just process each message on the queue. If you want a different message type, subscribe to a different queue.
  • ???

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

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

发布评论

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

评论(2

白况 2024-09-08 21:36:55

任何给定的 MQ 系统都应该能够处理任何给定队列中的数百万条消息,我根本不会担心。

我更喜欢具有独特现实意义的队列,而不是担心选择器。我知道有真正的理由使用选择器或消费并重新排队,但我更喜欢使队列不同而不用担心选择。

Any given MQ system should be able to handle many millions of messages in any given queue, I would not be concerned at all at voume.

I prefer queues that have distinct real-world meaning rather than worrying about selectors. I know there are real reasons to use selectors or to consume and re-queue, but I prefer to make the queues distinct and not worry about selection.

不再见 2024-09-08 21:36:55

由于这个问题没有得到真正解决,并且您在问题中询问了它(当我发现这个时,这是我正在寻找的东西),我想我可以插话如何在单个异构队列上过滤消息按类型。

如果您查看此处,您会发现一个用户定义的属性适用于所有名为 JMSType 的消息。这是一个String,默认为空。当您发送消息时,让生产者将其设置为商定的值,例如 maptext,然后在您的消费者中使用特定消息选择器取决于您想要接收的消息类型。使用相同的示例,它将是 JMSType = 'map'JMSType = 'text'

我能够使用 ActiveMQ 与 Java 生产者和 C++ 消费者成功使用此技术-CPP 库。

Since this wasn't really addressed and you asked about it in your question (and it was something I was searching for when I found this), I thought I could chime in on how I am able to filter messages on a single, heterogeneous queue by type.

If you look here, you will find a user-defined property is available on all messages called JMSType. This is a String and is empty by default. When you are sending messages, have your producer set this to an agreed upon value, such as map or text for example, and then, in your consumer, use a particular message selector depending on what kind of message you want to receive. Using the same examples, it would be JMSType = 'map' or JMSType = 'text'.

I was able to use this technique successfully with a Java producer and a C++ consumer using the ActiveMQ-CPP library.

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