在与生产者相同的应用程序中托管 NServiceBus 订阅者 [英] Hosting an NServiceBus subscriber in the same application as the producer

查看:48
本文介绍了在与生产者相同的应用程序中托管 NServiceBus 订阅者的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以使用 NServiceBus 在同一个应用程序中发布和使用消息,特别是在 Web 应用程序中?

Is it possible to use NServiceBus to publish and consume messages in the same application, specifically a web application?

将来我们几乎肯定需要维护一个单独的长时间运行的服务来处理此应用程序生成的消息,这就是为什么我们希望从一开始就使用 NServiceBus,但现在开始就很好当 web 应用程序启动时,消费者和发布者.这将使我们更轻松地进行测试和部署.

In the future we will almost certainly need to maintain a separate long running service to process messages generated by this application, and this is why we are hoping to use NServiceBus from the start, but right now it would be nice to just start up the consumer and the publisher when the web application starts. This will make testing and deployment far easier for us.

我想我需要引用 NServiceBus.Host.exe 并在 global.asax 中启动该进程,但需要关于我需要调用什么来执行此操作的帮助.

I presume I will need to reference the NServiceBus.Host.exe and start up the process in the global.asax, but need help on what exactly I need to call to do this.

推荐答案

这不是一种开箱即用的部署模式.虽然您可以通过为第二个 NServiceBus 端点手动创建一个额外的应用程序域来完成这项工作,但您可能还需要为其提供一个自定义配置源,当然还有它自己的队列.

This is not a mode of deployment that is supported out of the box. While you could make this work by manually creating an additional appdomain for the second NServiceBus endpoint, you'd also likely need to give it a custom configuration source, and of course its own queue.

总而言之,我建议将它作为一个单独的进程保留,即使它在同一个盒子上.话虽如此,如果您不想在网络应用之外管理 Windows 服务,您可以创建第二个网络应用来托管它,而不是使用通用主机.

All in all, I'd recommend keeping it as a separate process, even if it is on the same box. That being said, you can create a second web app to host it rather than using the generic host if you don't want to manage windows services in addition to web apps.

希望有所帮助.

这篇关于在与生产者相同的应用程序中托管 NServiceBus 订阅者的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆