NServiceBus,无需使用 IMessage/NServiceBus 引用向我的解决方案发送垃圾邮件
有没有人找到一种使用 NServiceBus 的智能方法,而不必为所有消息实现无用的 IMessage 标记接口?
特别是,当使用 DomainEvents 时,我绝对不想将我的域耦合到特定的服务总线实现。
Has anyone found a smart way to use NServiceBus, without having to implements that useless IMessage marker interface for all messages?
Especially, when using DomainEvents, I would absolutely hate to couple my domains to a specific servce bus implementation.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我刚刚注意到 Udi 正在添加 Unobtrusive 模式到 NServiceBus 3.0。看来
这将解决这个问题。甚至还有一个示例文章,但你会此时(2012 年 2 月)从 github 获取最新版本。如果您愿意忍受一些潜在的不稳定性来获取纯 POCO 消息,您可以尝试一下。
I just noticed that Udi is adding an Unobtrusive Mode to NServiceBus 3.0. It appears
that will address the issue. There's even a sample writeup, but you would have to pull the latest off github at this point (Feb 2012). If you're willing to put up with some potential instability to get pure POCO messages, you might give it a try.
需要 IMessage 接口,以便 NServiceBus 可以在序列化器中自动注册这些类型。使用域事件时,不建议直接在总线上发布它们 - 相反,域事件处理程序会将它们转换为服务级事件(继承 IMessage)。
The IMessage interface is needed so that NServiceBus can automatically register those types in the serializer. When using domain events, it isn't recommended to publish them directly on the bus - instead, a domain event handler would translate them to service-level events (which inherit IMessage).
您也许能够创建自己的接口来实现 NSB 标记接口,然后将 NSB 依赖项 ILMerge 到您自己的 DLL 中。这应该允许您只需要对您自己的 Dll 的引用,而不需要对 NSB 的外部引用。
这就是 NSB 对其自己的依赖项所做的事情,因此您应该能够扩展这个想法,但请务必检查这种方法的陷阱 - Udi 最近在博客中介绍了它
http://www.udidahan.com/2010/08/01/cautously-merging-il/
You might be able to create your own interfaces implementing the NSB marker interface and then ILMerge the NSB dependencies into your own DLL. This should allow you to only require references to your own Dll and no external references to NSB.
Its what NSB does for its own dependencies so you should be able to extend the idea, be sure to check out the pitfalls of this approach though - Udi blogged about it recently
http://www.udidahan.com/2010/08/01/cautiously-merging-il/
六个月后,这个问题仍然没有任何进展(修复/改进)?
可能的解决方案摘要:
1) ILMerge 或..
2) 用于自定义包装消息的自定义调度程序。
这一切都是因为 IMessage 标记接口。
Six months later, still nothing about this issue (fix/improve) ??
Summary of possible solutions:
1) ILMerge or..
2) Custom Dispatcher for custom wrapped messages.
All this because of the IMessage marker interface.