简体   繁体   中英

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.

In my app.config the endpoints get changed by Octopus, depending on which environment I'm deploying to (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?

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 .

However, mapping of messages to endpoints should not change from testing to production. It is possible that with MSMQ, your machine names might change. There's an alternative with FileBasedRouting . This was an original NServiceBus project in ParticularLabs but migrated to Tim Bussmann his repo.

Although MSMQ is considered dead . 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. 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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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