pardahlman / RawRabbit

A modern .NET framework for communication over RabbitMq
MIT License
747 stars 144 forks source link

Need to disabled NameSuffix property of QueueConfiguration #210

Closed waldo2188 closed 7 years ago

waldo2188 commented 7 years ago

Hi, First of all, your library is really helpful, so thank for your contribution.

I use the version 1.10.3.

I'm facing an issue when I try to subscribe to a queue. The exchange and the queue is setup directly in RabbitMQ. So when I use this kind of code :

_client.SubscribeAsync<EmailCreation>(ServeValuesAsync, c => {
                c.WithExchange(e => {
                    e.WithName("e-emailing");
                    e.WithType(ExchangeType.Direct);
                    });
                c.WithQueue(q => {
                    q.WithName("q-email_creation");
                });
                c.WithRoutingKey("email_create");
            });

The queue name is suffixed with some path q-email_creation_/app/bin/debug/netcoreapp1_1/myapp, and it makes my RabbitMQ sad.

So I've tried to set a empty value to NameSuffix, but I can't because NameSuffix isn't a part of IQueueConfigurationBuilder.

How can I disable NameSuffix ?

pardahlman commented 7 years ago

Hello, @waldo2188 - thanks for reporting this!

The queue suffix that you get by default is actually supposed to be the application name, however it is primed for applications running on windows, but will be fixed in #193 to support other platforms.

It is the INamingConventions that is used to generate the queue suffix, using delegate SubscriberQueueSuffix. You should be able to get rid of the queue suffix by implementing your own INamingStrategy and register it when you create the client. You can have a look at the sample code to see how to register custom implementations of RawRabbit internals

services
  .AddRawRabbit(
    Configuration.GetSection("RawRabbit"),
    ioc => ioc.AddSingleton<INamingConventions, CustomNamingConventions>()
);

Hope this helps!

waldo2188 commented 7 years ago

Thanks. That's work fine.