Naming Conventions

Component: Azure Service Bus Transport (Legacy)
NuGet Package NServiceBus.Azure.Transports.WindowsAzureServiceBus (6.x)
Target NServiceBus Version: 5.x
Standard support for version 5.x of NServiceBus has expired. For more information see our Support Policy.
This page refers to the legacy Azure Service Bus transport, which is rendered obsolete by the Azure Service Bus transport built to target both .NET Framework and .NET Core. All new projects should use the new Azure Service Bus transport.

Versions 6 and below

Naming Conventions

To have a fine-grained control over entity names generated by the ASB transport, the NamingConventions class exposes several naming conventions that can be overwritten.

Entity sanitization:

6.4 NServiceBus.Azure.Transports.WindowsAzureServiceBus
NamingConventions.EntitySanitizationConvention = (entityName, entityType) =>
{
    if (entityType == EntityType.Queue || entityType == EntityType.Topic)
    {
        var regexQueueAndTopicValidCharacters = new Regex(@"[^a-zA-Z0-9\-\._\/]");
        var regexLeadingAndTrailingForwardSlashes = new Regex(@"^\/|\/$");

        var result = regexQueueAndTopicValidCharacters.Replace(entityName, "");
        return regexLeadingAndTrailingForwardSlashes.Replace(result, "");
    }

    // Subscription
    var regexSubscriptionValidCharacters = new Regex(@"[^a-zA-Z0-9\-\._]");
    return regexSubscriptionValidCharacters.Replace(entityName, "");
};

This sanitization allows forward slash / in queue and topic names unlike default sanitization convention used by Azure Service Bus transport.

Entities creation:

6.4 NServiceBus.Azure.Transports.WindowsAzureServiceBus
NamingConventions.QueueNamingConvention = (settings, messageType, queue, doNotIndividualize) =>
{
    return DetermineQueueNameUsingCustomLogic(settings, messageType, queue, doNotIndividualize);
};

NamingConventions.TopicNamingConvention = (settings, messageType, endpointName) =>
{
    return DetermineTopicNameUsingCustomLogic(settings, messageType, endpointName);
};

NamingConventions.SubscriptionNamingConvention = (settings, eventType, endpointName) =>
{
    return DetermineSubscriptionNameUsingCustomLogic(settings, eventType, endpointName);
};

NamingConventions.PublisherAddressConvention = (settings, address) =>
{
    return DeterminePublisherNameUsingCustomLogic(settings, address);
};

NamingConventions.QueueAddressConvention = (settings, address, doNotIndividualize) =>
{
    return DetermineQueueAddressUsingCustomLogic(settings, address, doNotIndividualize);
};

NamingConventions.PublisherAddressConvention = (settings, address) =>
{
    return DeterminePublisherAddressUsingCustomLogic(settings, address);
};
This is an advanced topic and requires full understanding of the topology.

Last modified