按主题名称或字符串属性过滤 JMS 消息更好?
使用 Apache ActiveMQ Artemis,是优先使用一个带有用于区分它们的 String 属性的主题还是多个主题?例如,出版商应该这样做:
jmsTemplate.convertAndSend("quotes", quote, m -> {
m.setStringProperty("symbol", "MSFT");
return m;
});
还是这样?
jmsTemplate.convertAndSend("quotes.MSFT", quote, m -> {
m.setStringProperty("symbol", "MSFT");
return m;
});
请注意,我不能只是这样做:
jmsTemplate.convertAndSend("quotes.MSFT", quote);
因为我需要将符号属性作为 default-last-value-key
:
<address-setting match="quote.#">
<retroactive-message-count>100000</retroactive-message-count>
<default-last-value-key>symbol</default-last-value-key>
<default-non-destructive>true</default-non-destructive>
可能有 100,000 个符号。创建这么多 pub/sub 主题会很糟糕吗?
大多数将没有订阅者,但将使用追溯地址保留最后的值。我将拥有 Java 和 Python (STOMP) 的消费者。
Using Apache ActiveMQ Artemis, is it preferred to have one topic with String
properties used to differentiate them or many topics? e.g., should publishers do this:
jmsTemplate.convertAndSend("quotes", quote, m -> {
m.setStringProperty("symbol", "MSFT");
return m;
});
or this?
jmsTemplate.convertAndSend("quotes.MSFT", quote, m -> {
m.setStringProperty("symbol", "MSFT");
return m;
});
Note that I can not just do:
jmsTemplate.convertAndSend("quotes.MSFT", quote);
because I need the symbol property as default-last-value-key
:
<address-setting match="quote.#">
<retroactive-message-count>100000</retroactive-message-count>
<default-last-value-key>symbol</default-last-value-key>
<default-non-destructive>true</default-non-destructive>
There could be 100,000 symbols. Would it be terrible to have so many pub/sub topics created?
Most will have no subscribers but will retain the last value using Retroactive Addresses. I will have consumers in Java and Python (STOMP).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
一般来说,ActiveMQ Artemis 没有任何内在的东西必然会推动您采取这种或另一种方式。
然而,您的用例对于追溯地址 + LVQ 配置来说是相当独特的。我在这里对使用单个地址的担忧是,如果确实有 100,000 个符号,并且应保留每个符号的最后一个值,那么支持追溯地址的环形队列可能需要 100,000 条消息深度,这意味着每次订阅在该地址上创建队列,然后代理将必须处理所有这些消息。我预计这将给经纪人带来沉重的负担。
因此,在这一点上我想说每个符号的地址可能是最好的。那么
retroactive-message-count
可以是1
。最终,我最好的建议是使用类似生产的负载实际测试这两种不同的配置,然后选择在性能、可管理性等方面最适合您的用例的配置。这种类型的问题总是在于细节的东西。在这样的背景下,有太多的移动部件和不言而喻的要求来提供权威的建议。
Generally speaking, there's nothing intrinsic about ActiveMQ Artemis that would necessarily push you one way or the other.
However, your use-case is rather unique with the retroactive-address + LVQ configuration. My concern here with using a single address is that if there really are 100,000 symbols and the last value for each symbol should be retained then the ring-queue backing the retroactive address will potentially need to be 100,000 messages deep which means that every time a subscription queue is created on that address then the broker will have to process all those messages. I expect that would be a significant burden on the broker.
Therefore, at this point I'd say that an address for each symbol is likely the best. Then the
retroactive-message-count
can be1
.Ultimately my best advice would be to actually test these two different configurations with a production-like load and then choose the one that best fits your use-case in terms of performance, manageability, etc. The devil is always in the details with this sort of thing. There are too many moving parts and unspoken requirements to provide an authoritative recommendation in a context like this.