如何在 NServiceBus 中按命名空间配置 MessageEndpointMapping
我试图通过将消息从不同的命名空间发送到不同的端点来在 NServiceBus 配置中配置消息端点映射。
因此,我在 web.config 中配置了以下内容:
<MessageEndpointMappings>
<add Messages="Company.Messages.Accounts" Endpoint="ServiceInput" />
<add Messages="Company.Messages.Payments" Endpoint="ServiceInput" />
<add Messages="Company.Messages.Cancellations" Endpoint="ServiceInput" />
<add Messages="Company.Messages.Notifications" Endpoint="ServiceInput" />
</MessageEndpointMappings>
但是,当我的应用程序启动时,我收到以下异常:
Spring.Objects.PropertyAccessExceptionsException: PropertyAccessExceptionsException (1 个错误);嵌套的 PropertyAccessException 是: [Spring.Core.TypeMismatchException:无法将类型 [System.Collections.Hashtable] 的属性值转换为属性“MessageOwners”所需的类型 [System.Collections.IDictionary]。,内部异常:System.ArgumentException:加载消息程序集时出现问题:公司.消息.付款---> System.IO.FileNotFoundException:无法加载文件或程序集“Company.Messages.Payments”或其依赖项之一。系统找不到指定的文件。 文件名:'Company.Messages.Payments'
我发现有趣的是它似乎找到了 Company.Messages.Accounts 但在第二个配置行上失败了。我想也许它不喜欢让它们全部转到同一个端点,但是更改此配置以让它们转到不同的端点并没有改变我收到的错误消息。
我做错了什么?是否无法按命名空间对消息进行分段(我所看到的只是按类型和程序集)?
谢谢, 史蒂夫
I am trying to configure my message endpoint mapping in my NServiceBus configuration by sending messages from different namespaces to different endpoints.
As such, I have configured the following in my web.config:
<MessageEndpointMappings>
<add Messages="Company.Messages.Accounts" Endpoint="ServiceInput" />
<add Messages="Company.Messages.Payments" Endpoint="ServiceInput" />
<add Messages="Company.Messages.Cancellations" Endpoint="ServiceInput" />
<add Messages="Company.Messages.Notifications" Endpoint="ServiceInput" />
</MessageEndpointMappings>
However, when my application starts, I receive the following exception:
Spring.Objects.PropertyAccessExceptionsException: PropertyAccessExceptionsException (1 errors); nested PropertyAccessExceptions are:
[Spring.Core.TypeMismatchException: Cannot convert property value of type [System.Collections.Hashtable] to required type [System.Collections.IDictionary] for property 'MessageOwners'., Inner Exception: System.ArgumentException: Problem loading message assembly: Company.Messages.Payments ---> System.IO.FileNotFoundException: Could not load file or assembly 'Company.Messages.Payments' or one of its dependencies. The system cannot find the file specified.
File name: 'Company.Messages.Payments'
What I find interesting is that it seems to have found Company.Messages.Accounts but failed on the second configured line. I thought that maybe it didn't like have them all go to the same endpoint, but changing this configuration to have them go different endpoints didn't change the error message I received.
What am I doing wrong? Is it not possible to segment messages by namespace (all I have seen is by type and by assembly)?
Thanks,
Steve
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
NSB 仅支持将程序集或单个类型映射到端点。不支持命名空间,我建议您将消息程序集拆分为每个端点的单独程序集。
NSB only supports mapping of assemblies or individual types to endpoints. Namespaces are not supported, I suggest you split you message assembly into separate assemblies for each of your endpoints.
根据此页面您可以指定一个类型:
http://docs.pspecial.net/nservicebus/messaging/message-owner
可以使用其限定名称来配置特定类型:“namespace.type, assembly”。
According to this page you can specify a type:
http://docs.particular.net/nservicebus/messaging/message-owner
Specific types can be configured by using their qualified name: "namespace.type, assembly".
从 NServiceBus v3.3 开始,命名空间可用于过滤消息映射
http://docs.prefer .net/nservicebus/messaging/消息所有者
As of NServiceBus v3.3 namespaces can be used to filter message mappings
http://docs.particular.net/nservicebus/messaging/message-owner