JMS 消息选择器 - 消耗其他所有内容/捕获所有/默认情况
假设我有一个队列。我有 3 个消费者使用以下选择器从该队列中读取数据:
consumer1: myMessageType = 'Funny'
consumer2: myMessageType = 'Sad'
consumer3: no selector defined
现在我像这样在队列中发送一堆消息...
Message 1 : myMessageType = 'Funny'
Message 2 : myMessageType = 'Funny'
Message 3 : myMessageType = 'Funny'
Message 4 : myMessageType = 'Funny'
Message 5 : myMessageType = 'Sad'
Message 6 : myMessageType = 'Sad'
Message 7 : myMessageType = 'Sad'
Message 8 : myMessageType = 'Sad'
Message 9 : myMessageType = 'Weird'
Message 10: myMessageType = 'Weird'
Message 11: myMessageType = 'Weird'
Message 12: myMessageType = 'Weird'
没有定义消息选择器的 Consumer3 是否只会接收 myMessageType = 'Weird' 的消息?或者consumer3会收到所有消息类型吗?
我显然已经根据现实世界的用例简化了我的问题。我们将有许多带有消息选择器的消费者,并试图弄清楚是否可以使用没有消息选择器的消费者来处理与任何其他消费者的选择器不匹配的每条消息。
我已经搜索过,但无法找到这个问题的明确答案。我想过编写一些代码来测试它,但担心幕后的许多变量(预取、缓存、并发等)可能会给我带来误导性的结果。最后,我还担心,如果规范中未明确指定,则代理之间的行为可能会有所不同。我希望有人知道具体的答案。
Suppose I have a single queue. I have 3 consumers reading from that queue with the following selectors:
consumer1: myMessageType = 'Funny'
consumer2: myMessageType = 'Sad'
consumer3: no selector defined
Now I send a bunch of messages in the queue like this...
Message 1 : myMessageType = 'Funny'
Message 2 : myMessageType = 'Funny'
Message 3 : myMessageType = 'Funny'
Message 4 : myMessageType = 'Funny'
Message 5 : myMessageType = 'Sad'
Message 6 : myMessageType = 'Sad'
Message 7 : myMessageType = 'Sad'
Message 8 : myMessageType = 'Sad'
Message 9 : myMessageType = 'Weird'
Message 10: myMessageType = 'Weird'
Message 11: myMessageType = 'Weird'
Message 12: myMessageType = 'Weird'
Will consumer3, with no message selector defined, only receive messages where myMessageType = 'Weird'? Or will consumer3 receive all the message types?
I've obviously simplified my question from our real world use case. We'll have many consumers with message selectors and are trying to figure out if we can use a consumer with no message selector to handle every message that doesn't match the selectors of any other consumer.
I've searched and have been unable to find a definitive answer to this question. I thought about writing some code to test it but worry that many variables under the covers (prefetch, caching, concurrency, etc) might give me a misleading result. Lastly I'm also concerned the behavior might be different from broker to broker if not explicitly specified in the specification. I'm hoping someone might know the concrete answer.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
没有选择器的 JMS 消费者可以接收任何消息,无论其他消费者使用什么选择器。因此,为了获得您想要的行为,您需要为任何不匹配的消息创建一个“相反”选择器,如您所描述的。
A JMS consumer without a selector can receive any message, regardless of what selectors other consumers are using. Therefore, to get the behavior you want you need to create an "opposite" selector, as you described, for any message that doesn't match.