Search code examples
azurenservicebusnservicebus5

Why does NServiceBus on Azure not use my specified endpoint name?


I have a console app that uses NServiceBus to publish a message to an Azure topic. However, NServiceBus creates a new topic with a different name, instead of the one I specified. Why is this?

More details

My message configuration looks as follows. This means that messages of Type 'TheResponse' should go to a Topic with the name, "test1", right?

<UnicastBusConfig>
    <MessageEndpointMappings>

        <add Assembly="Messages" Type="Messages.TheResponse" Endpoint="test1"/>

    </MessageEndpointMappings>
</UnicastBusConfig>

<connectionStrings>
    <add name="NServiceBus/Transport"
        connectionString="Endpoint=sb://[my-namespace].servicebus.windows.net/;SharedSecretIssuer=[issuer];SharedSecretValue=[key]"></add>
</connectionStrings>

What happens in reality is that NServiceBus creates a new Topic on Azure in the format MyAssemblyName-MyMachineName.events.

We use the Azure Service Bus transport.

How do I get NServiceBus to publish events to a specific Topic? Do I misunderstand the purpose of the MessageEndpointMappings?


Solution

  • Azure servicebus does not allow to name multiple entities of different types with the same name, so each endpoint defines an input queue named after the endpoint name and a publishing topic with '.events' appended.

    You cannot publish to a specific topic, an endpoint can only publish on it's own topic and subscribers can decide to listen to specific endpoints.

    Your mapping file actually says, all messages/commands of type Messages.TheResponse should be sent to the input queue of endpoint 'test1', or in case that TheResponse would be an event: please subscribe to the publishing topic of endpoint 'test1'