Naming Conventions

This page refers to the deprecated legacy Azure Service Bus transport that uses the WindowsAzure.ServiceBus NuGet package. All users should migrate to the Azure Service Bus transport 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:

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:

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