在与生产者相同的应用程序中托管 NServiceBus 订阅者

发布于 2024-08-25 06:38:39 字数 265 浏览 3 评论 0原文

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

将来我们几乎肯定需要维护一个单独的长时间运行的服务来处理该应用程序生成的消息,这就是为什么我们希望从一开始就使用 NServiceBus,但现在最好只启动消费者以及 Web 应用程序启动时的发布者。这将使我们的测试和部署变得更加容易。

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

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

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.

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

心奴独伤 2024-09-01 06:38:39

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

总而言之,我建议将其保留为一个单独的进程,即使它位于同一个盒子上。话虽这么说,如果您不想在 Web 应用程序之外管理 Windows 服务,则可以创建第二个 Web 应用程序来托管它,而不是使用通用主机。

希望有帮助。

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.

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.

Hope that helps.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文