IoC、容器和 NServiceBus 混淆
这是我的设置
- Castle Windsor 是我的容器
- NServiceBus 本身在内部使用它自己的容器,Spring 默认情况下
- 我正在实现 PubSub 配置。
好的,如果我的 Bus.Publish 发生在我的 IWantToRunAtStartup 类中,那么一切都很好。作为对 Run() 的测试,我们可以启动一个计时器,它将进入服务样式循环。
但是,如果我想从我的应用程序中抽象 NServiceBus,并让我的应用程序继续运行,该怎么办:
new CustomPulisherClass().Notify(ISomeMessage msg);
在这种情况下,我如何实现 CustomPublisherClass。
我的困惑来自于 NServiceBus 已经作为服务运行,它已经“启动”了。如何获取 Bus 对象的正确实例?
Here is my setup
- Castle Windsor is my container
- NServiceBus is itself using it's own container internally, Spring by default
- I'm implementing the PubSub config.
Ok, if I have my Bus.Publish happening within my IWantToRunAtStartup class, then everything is fine. As a test for example on Run() we can start a timer and it'll go into a Service style loop.
However, what if I want to abstract NServiceBus from my app, and have my app go:
new CustomPulisherClass().Notify(ISomeMessage msg);
In this situation, how do I implement CustomPublisherClass.
My confusion is coming from the fact that NServiceBus is already running as a Service, it's already been "Started". How to I get at the correct instance of the Bus object?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您应该配置 NServiceBus 以使用 Windsor 作为内部容器:
http:// sourceforge.net/apps/mediawiki/nservicebus/index.php?title=Additional_containers
如果您这样做,正确的 IBus 将在您的 Windsor 实例中可用
You should configure NServiceBus to use Windsor as the internal container:
http://sourceforge.net/apps/mediawiki/nservicebus/index.php?title=Additional_containers
If you do that the correct IBus will be available in your instance of Windsor