实现 JMS 请求-答复。队列与主题?
我知道有不同的方法(或排列)来实现 JMS 请求-答复机制,即请求队列和响应队列、请求主题和响应主题,或两者的混合。
我想知道的是,(1)推荐的(或最常见的)方式是什么以及(2)不同的排列如何衡量?
接下来,这样说是不是更正确 一个。 “向队列发送消息”或 b. “通过队列发送消息”?
干杯!
I understand that there are different ways (or permutations) to implementing a JMS Request-Reply mechanism, i.e. request queue and response queue, request topic and response topic, or a mix of either.
What I would like to know is, (1) what is the recommended (or most common) way and (2) how do the different permutations measure up?
Next, is it more correct to say
a. "Send a message to a queue" or b. "Send a message through a queue"?
Cheers!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
通常,使用队列。 “请求”意味着收件人,而不是对任何关心的人的通知,因此您可能需要队列的行为。
队列通常对一件事情(或有限数量的对等事物)接收消息并处理它做得更好。当消息真正到达处理它的人手中很重要时,他们也倾向于比主题更明智的持久性模型。 (例如:如果丢弃消息是一个问题,您可能需要一个队列)
主题更加面向广播:说一些话,任何关心的人都会听到它。通常,这与“……预计不会有直接响应”密切相关,因为“零个或多个听众”模型……好吧,如果您期望得到响应,那么零个听众始终是一个问题。
主题可以持久,但规则很奇怪,而且很少是你真正想要的。
最后,我认为大多数人说“到”队列,因为队列和处理消息的事物是不同的,但实际上,当你传达你的意思时,它并不像日志那么重要。
Normally, use a queue. "Request" implies a recipient, not a notice to anyone who cares, so you probably want the behaviour of a queue.
Queues usually do better for one thing - or a limited number of peer things - receiving the message and processing it. They also tend to saner persistence models than topic, when it matters that the message actually get to someone who processes it. (eg: if dropping the message is a problem, you probably want a queue)
Topics are more broadcast oriented: say something, and anyone who cares will hear about it. Normally that goes hand-in-hand with "...and no direct response is expected" because the "zero or more listeners" model ... well, zero listeners is always a problem if you expect a response.
Topics can do persistence, but the rules are stranger, and seldom what you actually want.
Finally, I think most people say "to" a queue, because the queue and the thing(s) processing messages off it are distinct, but really, it doesn't matter much as log as you convey your meaning.
此外,使用队列,您可以让多个订阅者处理消息,因此它是内置负载均衡器的孩子。您无法通过主题轻松做到这一点。
Also with a Queue you are able to have multiple subscribers process the messages so its kid of a built in loadbalancer. You cannot do this easily with a Topic.