nServiceBus 的多个配置文件 - 同一目录
我正在尝试找到一种方法来支持来自同一安装目录的 nServiceBus 的多种配置(但作为单独的进程运行)。目前人们如何做到这一点?
我知道:
- 您可以使用以下方式以编程方式更改参数
NServiceBus.Configure 。和() ... .MsmqTransport() .Configurer.ConfigureComponent
(NServiceBus.ObjectBuilder.ComponentCallModelEnum.None) .ConfigureProperty(x => x.InputQueue, "DynamicInputQueue1") .ConfigureProperty(x => x.ErrorQueue, "DynamicErrorQueue1");
- 您可以使用以下命令安装服务的多个“实例”:
NServiceBus.Host.exe /install /serviceName:xyz /instance:abc
但我想将两者结合起来,以便实例名称影响我们采用的配置路线。所以我想这可以归结为 - 我怎样才能获取实例名称?或者我可以为此采取替代路线,而无需每个实例诉诸多个单独的安装目录和 app.configs ?
谢谢
I'm trying to find a way to support multiple configurations for nServiceBus from the same installation directory (but running as separate processes). How do folks do this at the moment?
I know that:
- you can programmatically change parameters using
NServiceBus.Configure .With() ... .MsmqTransport() .Configurer.ConfigureComponent<MsmqTransport> (NServiceBus.ObjectBuilder.ComponentCallModelEnum.None) .ConfigureProperty(x => x.InputQueue, "DynamicInputQueue1") .ConfigureProperty(x => x.ErrorQueue, "DynamicErrorQueue1");
- and you can install multiple "instances" of a service using:
NServiceBus.Host.exe /install /serviceName:xyz /instance:abc
but I'd like to combine the two so the instance name influences which configuration route we take. So I guess it comes down to this - how can I fetch the instance name? Or are there alternative routes I could be taking for this, without resorting to multiple separate installation directories and app.configs per instance?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为从维护的角度来看,您可能需要不同的目录来使管理人员变得简单,但如果您想要单个目录,您可能可以使用以下方法之一。
您可能需要考虑实施自定义配置文件。配置文件名称在命令行上提供,允许您根据配置文件调整设置。 OOTB NSB 有 3 个配置文件:Lite、Integration 和 Production,它们会根据环境更改设置。您可以创建自己的并使用配置文件提供不同的设置。只需实现 IProfile,然后在命令行上提供它即可。
另一种选择可能是实现 IConfigurationSource 并从您决定的任何位置提取数据。这可以是多个文件、数据库或其他东西。
最后,您可以将配置放入不同的程序集中,并利用 NSB 容器使用 .With 在上面的引导代码中加载适当的配置(此处的程序集列表包括正确的配置程序集)。这可能可以通过实现 IWantToRunAtStartup 来完成,但请检查以确保您在服务生命周期的正确时间点调整配置。
I think from a maintenance standpoint, you may want different directories to make it simple for your administrative folks, but if you want a single directory, you can probably use one of the following methods.
You may want to consider implementing a custom Profile. The Profile name is supplied on the command line and allows you to tweak settings based on the Profile. OOTB NSB has 3 profiles, Lite, Integration, and Production which change settings based on an environment. You could create your own and supply different settings using the Profile. Just implement IProfile and then supply it on the command line.
Another option may be to implement IConfigurationSource and pull data from wherever you decide. This could be multiple files, a database, or something else.
Lastly you could put your configuration into different assemblies and leverage the NSB container to load the appropriate configuration in your bootstrap code above using .With(your list of assemblies here include the correct configuration assembly). This can probably be done implementing IWantToRunAtStartup, but check to make sure you are tweaking the config at the right point in the lifetime of the service.