简体   繁体   English

map 端点如何在 NServiceBus 7 中被 Octopus 更改为不同的环境?

[英]How to map endpoints that get changed by Octopus for different environments in NServiceBus 7?

I'm upgrading NServiceBus to version 7 and the configuration block <UnicastBusconfig> in app.config has been deprecated according to the upgrade guide and should now be configured in-code.我正在将 NServiceBus 升级到版本 7,根据升级指南app.config中的配置块<UnicastBusconfig>已被弃用,现在应该在代码中进行配置。

In my app.config the endpoints get changed by Octopus, depending on which environment I'm deploying to (dev/staging/prod).在我的app.config中,Octopus 会更改端点,具体取决于我部署到的环境 (dev/staging/prod)。

<UnicastBusConfig>
  <MessageEndpointMappings>
    <add Messages="project_A" Endpoint="project_A_dev" />
    <add Messages="project_B" Endpoint="project_B_dev" />
    <add Messages="project_C" Endpoint="project_C_dev" />
    <add Messages="project_D" Endpoint="project_D_dev" />
  </MessageEndpointMappings>
</UnicastBusConfig>

How can I map these endpoints in-code and have them still overwritable by Octopus?我如何在代码中 map 这些端点并让它们仍然可以被八达通覆盖?

How to upgrade is described here . 此处介绍了如何升级。 Because when .NET Core was released, the default was configuration in code over application configuration files like app.config and web.config .因为当 .NET Core 发布时,默认是通过应用程序配置文件(如app.configweb.config )在代码中进行配置。

However, mapping of messages to endpoints should not change from testing to production.但是,消息到端点的映射不应从测试更改为生产。 It is possible that with MSMQ, your machine names might change.使用 MSMQ,您的机器名称可能会更改。 There's an alternative with FileBasedRouting . FileBasedRouting有一个替代方案。 This was an original NServiceBus project in ParticularLabs but migrated to Tim Bussmann his repo.这是 ParticularLabs 中的一个原始NServiceBus 项目,但已迁移到 Tim Bussmann 他的回购。

Although MSMQ is considered dead .虽然MSMQ算是死了 You might want to start using the NServiceBus Bridge to move away from MSMQ onto another transport, because at some point Microsoft will remove support and remove it from Windows. If you'd like more info on the Bridge, contact support at Particular Software.您可能想要开始使用NServiceBus Bridge以从 MSMQ 转移到另一种传输方式,因为在某些时候 Microsoft 将删除支持并将其从 Windows 中删除。如果您想了解有关 Bridge 的更多信息,请联系 Particular Software 的支持人员。 If you'd like, mention my name and I'll respond;-)如果您愿意,请提及我的名字,我会回复;-)

If you really need to have different endpoints for a message based on environment then you can use your own settings in an app.config that are read into the code configuration for the destination.如果您确实需要根据环境为一条消息设置不同的端点,那么您可以在 app.config 中使用您自己的设置,这些设置已读入目标的代码配置中。

routing.RouteToEndpoint(
    assembly: typeof(AcceptOrder).Assembly,
    @namespace: "PriorityMessages",
    destination: "READ_THIS_FROM_app.config");

You can then use Octopus to modify those config settings based on your environment.然后,您可以使用 Octopus 根据您的环境修改这些配置设置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM