MessageEndpointMappings 如何知道设置订阅与传出消息?
我在 App.config 中看到 MessageEndpointMappings 部分,它一直让我感到困惑。
有时它看起来像是设置一个客户端来订阅另一个队列(就像这个):
<UnicastBusConfig>
<MessageEndpointMappings>
<add Messages="MyServiceBus.MessageHub.Contracts" Endpoint="MessageHub"/>
</MessageEndpointMappings>
</UnicastBusConfig>
但其他时候它似乎用于将传出消息配置到其他队列:
<UnicastBusConfig>
<MessageEndpointMappings>
<add Messages="ServiceBus.MessageHub.InternalMessages" Endpoint="MessageHub"/>
</MessageEndpointMappings>
</UnicastBusConfig>
但实际上,它们两者之间没有区别。 那么它如何知道何时设置订阅以及何时设置发送消息?
或者它真的一直在执行这两项操作而我只是不使用这两者?
I see MessageEndpointMappings section in my App.config and it just keeps confusing me.
Sometimes it looks like it sets of a client to subscribe to another queue (like this one does):
<UnicastBusConfig>
<MessageEndpointMappings>
<add Messages="MyServiceBus.MessageHub.Contracts" Endpoint="MessageHub"/>
</MessageEndpointMappings>
</UnicastBusConfig>
But other times it seems to be used to configure outgoing messages to other queues:
<UnicastBusConfig>
<MessageEndpointMappings>
<add Messages="ServiceBus.MessageHub.InternalMessages" Endpoint="MessageHub"/>
</MessageEndpointMappings>
</UnicastBusConfig>
But really, there is no difference between the two of them. So how does it know when to setup a subscription and when to setup for sending messages?
Or is it really doing both all the time and I just don't use both?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
本质上,您使用
MessageEndpointMappings
元素声明的是“谁是指定消息的所有者?”另一种看待它的方式是,这是服务依赖项的方向,而不是消息流,因为这是由消息是否得到
Send
t 或决定的发布
d.因此,为了能够从给定服务发送消息和订阅消息,您需要在发送者/订阅者端声明一个端点映射。
然后,当发送者/订阅者有一个指向另一个服务的端点映射以及该端点映射中包含的消息的处理程序时,NServiceBus 足以自动订阅该消息(除非您禁用使用
DoNotAutoSubscribe()
进行自动订阅) - 因为从逻辑上讲,这必定意味着发送者/订阅者希望订阅给定的消息。当你这样想的时候,我觉得这是有道理的。希望你也有这样的感觉:)
Essentially, what you're declaring with the
MessageEndpointMappings
element, is "who is the owner of the specified messages?"Another way to view it, is that this is the direction of the service dependency - not the message flow, because that is determined by whether messages get
Send
t orPublish
d.Therefore, in order to be able to send messages and subscribe to messages from a given service, you declare an endpoint mapping in the sender/subscriber end.
And then, when the sender/subscriber has an endpoint mapping that points to another service and a handler for a message included in that endpoint mapping, NServiceBus is nice enough to automatically subscribe to that message (unless you disable the auto-subscription with
DoNotAutoSubscribe()
) - because, logically, that must mean that the sender/subscriber wishes to subscribe to the given message.When you think about it this way, I think it makes sense. Hope you feel so too :)