rebus-org / Rebus.AzureServiceBus

:bus: Azure Service Bus transport for Rebus
https://mookid.dk/category/rebus
Other
33 stars 20 forks source link

LegacyV3NameFormatter.FormatQueueName is not compatibe with Rebus up to 6.0.3 #56

Open gaevoy opened 4 years ago

gaevoy commented 4 years ago

LegacyV3NameFormatter.FormatQueueName is not compatible with naming convention of Rebus up to 6.0.3. Same goes to LegacyNameFormatter.

Also it would be nice to specify a version using .UseLegacyNaming(), for instance .UseLegacyNaming(RebusVersion.V6) or .UseLegacyNaming(RebusVersion.V3)

Before 7.x

Queue name: Foo-BAR-1 -> foo-bar-1 https://github.com/rebus-org/Rebus.AzureServiceBus/blob/6.0.7/Rebus.AzureServiceBus/AzureServiceBus/AzureServiceBusTransport.cs#L76

After 7.x

Queue name: Foo-BAR-1 -> foo_bar_1 https://github.com/rebus-org/Rebus.AzureServiceBus/blob/7.1.3/Rebus.AzureServiceBus/AzureServiceBus/AzureServiceBusTransport.cs#L101 https://github.com/rebus-org/Rebus.AzureServiceBus/blob/7.1.3/Rebus.AzureServiceBus/AzureServiceBus/NameFormat/LegacyV3NameFormatter.cs#L14-L22

Workaround

public class LegacyV3NameFormatterFixed : INameFormatter
{
    private static readonly LegacyV3NameFormatter Original = new LegacyV3NameFormatter();

    public string FormatQueueName(string queueName)
    {
        return queueName.ToLowerInvariant();
    }

    public string FormatSubscriptionName(string subscriptionName)
    {
        return Original.FormatSubscriptionName(subscriptionName);
    }

    public string FormatTopicName(string topicName)
    {
        return Original.FormatTopicName(topicName);
    }
}
// boot logic
_activator = new BuiltinHandlerActivator();
Configure.With(_activator)
.Transport(t => t.UseAzureServiceBusAsOneWayClient("...").UseLegacyNaming())
.Options(o => o.Decorate<INameFormatter>(_ => new LegacyV3NameFormatterFixed()))
.Start();
mookid8000 commented 4 years ago

Hi @gaevoy , but.... my memory might be failing me, but I think the point of "legacy naming" with Rebus' Azure Service Bus transport v7 is to emulate the naming of v6, including its tendency to be overly conservative with queue names.

It shouldn't have any relation to the version of Rebus you're using, so if that's the case for you, then that's something we'll need to investigate...

gaevoy commented 4 years ago

It shouldn't have any relation to the version of Rebus you're using

Right. I mean version of Rebus.AzureServiceBus. So main issue it is not backward compatible with previous version.

I guess, it is okay but should be easy way how to configure it.

mookid8000 commented 4 years ago

Hmm.... I must admit I'm very hesitant to make additional changes regarding naming, because we've made such a mess already 😁 I'm afraid I'll make things even more confusing.