0

I'm in the process of upgrading my application from NServiceBus 4 to 5.

I have a class that implements IWantToRunWhenBusStartsAndStops and on the Start() method I print out the EndpointName - taking it from NServiceBus.Configure.EndpointName

On NServiceBus 5 it is deprecated and I want to do it correctly. How can I get the EndpointName?

developer82
  • 13,237
  • 21
  • 88
  • 153

1 Answers1

3

You can use a ReadOnlySetting instance, take a look at the following sample:

class MyClass : IWantToRunWhenBusStartsAndStops
{
    public ReadOnlySettings Settings{ get; set; }

    public void Start()
    {
        var name = this.Settings.EndpointName();
    }

    public void Stop()
    {

    }
}

Where EndpointName() is an extension method provided by NServiceBus in the NServiceBus namespace.

Mauro Servienti
  • 508
  • 2
  • 8