pardahlman / RawRabbit

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

Multiple consumers not working #389

Closed nicolaslawdune closed 5 years ago

nicolaslawdune commented 5 years ago

I try to launch two consumers at the same time consuming the same queue, but only the first one is registered on RabbitMQ. In the queue info, I only see one consumer. When I kill the first launching consumer, the queue disappears.

Here is my configuration

"RabbitMq" : { "Username": "username-dev", "Password": "password-dev", "VirtualHost": "vhost-dev", "Port": 5672, "Hostnames": [ "myhostname" ], "RequestTimeout": "00:00:10", "PublishConfirmTimeout": "00:00:10", "RecoveryInterval": "00:00:10", "PersistentDeliveryMode": true, "AutoCloseConnection": true, "AutomaticRecovery": true, "TopologyRecovery": true, "Exchange": { "Durable": true, "AutoDelete": true, "Type": "Topic" }, "Queue": { "AutoDelete": true, "Durable": true, "Exclusive": true } }

In the startup.cs :

RawRabbitFactory.CreateSingleton(new RawRabbitOptions { ClientConfiguration = options }); services.AddSingleton<IBusClient>(_ => client);

I subscribe to my queue :

public static Task SubscribeCommandHandlerAsync<TCommand>(this IBusClient bus, ICommandHandler<TCommand> handler) where TCommand : ICommand => bus.SubscribeAsync<TCommand>(msg => handler.HandleAsync(msg), ctx => ctx.UseSubscribeConfiguration(cfg => cfg.FromDeclaredQueue(q => q.WithName(GetQueueName<TCommand>()))));

I use .net core 2.0 and rawrabbit 2.0.0-rc5.

Thank you for your help.

nicolaslawdune commented 5 years ago

I finally round my mistake. M’y queue is configured to be exclusive for one instance. I have to turn off Exclusive Into config