Specify Endpoint Name

When using the configuration API

Define a convention in the endpoint initialization code using this:

6-pre NServiceBus
var endpointConfiguration = new EndpointConfiguration("MyEndpoint");
5.x NServiceBus
busConfiguration.EndpointName("MyEndpoint");
4.x NServiceBus
// To customize the endpoint name via code using the DefineEndpointName method,
// it is important to call it first, right after the With() configuration entry point.
configure.DefineEndpointName("MyEndpoint");
3.x NServiceBus
// To customize the endpoint name via code use the DefineEndpointName method,
// it is important to call it first, right after the With() configuration entry point.
configure.DefineEndpointName("MyEndpoint");

When using the NServiceBus.Host.exe

Namespace convention

When using NServiceBus.Host, the namespace of the class implementing IConfigureThisEndpoint will be used as the endpoint name as the default convention. In the following example the endpoint name when running NServiceBus host becomes MyServer. This is the recommended way to name a endpoint. Also this emphasizes convention over configuration approach.

7-pre NServiceBus.Host
namespace MyServer
{
    using NServiceBus;

    public class EndpointConfigByNamespace :
        IConfigureThisEndpoint,
        AsA_Server
    {
        // ... custom config
4.x - 6.x NServiceBus.Host
namespace MyServer
{
    using NServiceBus;

    public class EndpointConfigByNamespace :
        IConfigureThisEndpoint,
        AsA_Server
    {
        // ... custom config

EndpointName attribute

Set the endpoint name using the [EndpointName] attribute on the endpoint configuration.

This will only work when using NServiceBus host.
7-pre NServiceBus.Host
[EndpointName("MyEndpointName")]
public class EndpointConfigWithAttribute :
    IConfigureThisEndpoint, AsA_Server
{
    // ... custom config
5.x - 6.x NServiceBus.Host
[EndpointName("MyEndpointName")]
public class EndpointConfigWithAttribute :
    IConfigureThisEndpoint,
    AsA_Server
{
    // ... the config
4.x NServiceBus.Host
[EndpointName("MyEndpointName")]
public class EndpointConfigWithAttribute :
    IConfigureThisEndpoint,
    AsA_Server
{
    // ... custom config

Installation parameter

When specifying an explicit service name when installing the NServiceBus host, this is used as the endpoint name: /serviceName:"MyEndpoint".

Command-line parameter

Specify a endpoint name when running the NServiceBus host: /endpointName:"MyEndpoint".

Only use code OR commandline/installation parameters.

Input queue

By default the endpoint's input queue name is the same as endpoint's name. The input queue name can be overridden in Versions 5 and above using the following API:

6-pre NServiceBus
var transport = endpointConfiguration.UseTransport<MyTransport>();
transport.AddAddressTranslationException(
    new EndpointInstance("MyEndpoint"), "MyEndpoint.Messages");
5.x NServiceBus
busConfiguration.OverrideLocalAddress("MyEndpoint.Messages");

Additionally, the actual queue name has to be passed to the endpoints that want to communicate with it:

5.x NServiceBus
<UnicastBusConfig>
  <MessageEndpointMappings>
    <add Assembly="Messages" 
         Endpoint="MyEndpoint.Messages" />
  </MessageEndpointMappings>
</UnicastBusConfig>
6-pre NServiceBus
var routing = endpointConfiguration.Routing();
routing.RouteToEndpoint(typeof(MyMessage), "MyEndpoint");
var transport = endpointConfiguration.UseTransport<MyTransport>();
transport.AddAddressTranslationException(
    new EndpointInstance("MyEndpoint"), "MyEndpoint.Messages");

In Versions 5 and below the overridden input queue is passed directly to the routing configuration. In Versions 6 and above the logical routing works on an endpoint name level. The endpoint name is passed to the routing configuration, and a separate API call is required to specify the name of its input queue.

In Versions 6 and above the same API is used to override the default translation of the endpoint name to the transport address (input queue name) for the endpoint's own input queue, as well as for any destination endpoints. To learn more about transport address generation in Versions 6 and above refer to the routing documentation.

Last modified