在单个应用程序/进程中创建多个 NServiceBus 发布者的推荐方法?

发布于 2024-11-02 16:47:33 字数 317 浏览 0 评论 0原文

我将拥有多个发布者,它们都是单个“应用程序”的逻辑组件。

尽管我非常努力地尝试分离关注点(即有许多独立的类库构成了域逻辑),但我仍然宁愿只有一个应用程序来部署、调试等。

我看过的所有示例都是如此似乎远远依赖于将发布者信息放入 app.config 中,而且看起来我只能以这种方式声明一个发布者。

看起来我也许可以使用 CustomConfigurationSource 方法,但我觉得我错过了一些更简单直接的东西。

是否有一种简单/推荐的方法可以使用通用主机或自托管在单个应用程序中创建多个发布者(每个发布者具有不同的事件类型)?

I'm going to have several publishers that are all logical components of a single "application".

Although I try pretty hard to separate concerns (i.e. there are many independent class libraries making up the domain logic), I'd still much rather have just one application to deploy, debug, etc.

All of the examples I've looked at so far seem to rely on putting the publisher information in the app.config, and it looks like I can only declare one publisher that way.

It looks like I might be able to use the CustomConfigurationSource method but I feel like I'm missing something far more straightforward and direct.

Is there a simple/recommended way to create multiple publishers (each with a different event type) in a single application, either using the generic host or with self-hosting?

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

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

发布评论

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

评论(1

偏爱你一生 2024-11-09 16:47:33

如果您遵循每个逻辑发布者发布不同事件类型的指导,并且没有两个逻辑发布者发布完全相同的类型,那就没问题。

遵循这一点,您可以在单个应用程序进程中“共同托管”一个或多个逻辑发布者。事实上,它们与完全相同的物理数据库表进行通信并不一定是个问题,因为它们彼此之间不会有任何重叠,也不会踩到彼此的脚趾。

只要您在代码中完成了逻辑分离,将它们放入同一物理进程并共享相同的物理资源(例如队列和数据库)就没有任何问题。

从那里,只需使用 NServiceBus.Host.exe(适用于 Windows 托管)启动即可。

Provided you're following the guidance of each logical publisher publishing different event types where no two logical publishers ever publish the exact same type, you're fine.

Following this enables you to have one or more logical publishers "co-hosted" in a single application process. The fact that they are talking to the exact same physical database table isn't necessarily a problem because they won't have any overlap with each other and they won't step on each others' toes.

As long as you've done the logical separation in code there isn't any problem with putting them into the same physical process and sharing the same physical resources such as queues and databases.

From there, just fire things up using NServiceBus.Host.exe (for Windows hosting) and you're good to go.

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