0

I am using Rebus and have seen some strange behavior. I do expect that my application (Endpoint) would open only one Connection to the RabbitMQ Server and this connection will be used as a Singleton. However I have seen that the number of connections from my end point to the server increases over time a thing that leads to RabbitMQ server to crash.

Multiple connections from a rebus end point

I would like to know if there is any way to limit the number of connections that the rebus endpoint can open to RabbitMQ server.

In the method public void ConfigureServices(IServiceCollection services) we have

services.AutoRegisterHandlersFromAssemblyOf<RegisterMemberEventHandler>();
services.AddRebus(configure => configure
                        .Logging(l => l.Serilog())
                        .Transport(t => t.UseRabbitMq($"amqp://{UserName}:{Password}@{HostName}:{PortNo}", $"{EndPointQueue}")
                                        .ClientConnectionName("OMRSAPI")
                                        )
                        .Options(o =>
                        {
                            o.SetNumberOfWorkers(NumberOfWorkers);//10
                            o.SetMaxParallelism(MaxParallelism);//20
                            o.HandleMessagesInsideTransactionScope();
                            o.Decorate<IErrorHandler>(c => {
                                var errorHandler = c.Get<IErrorHandler>();
                                var loggerFactory = c.Get<IRebusLoggerFactory>();
                                var bus = c.Get<IBus>();
                                var transport = c.Get<ITransport>();
                                return new ErrorMessageHandler(errorHandler, loggerFactory,settings,bus,transport);
                            });
                            o.SimpleRetryStrategy(maxDeliveryAttempts: 3, secondLevelRetriesEnabled: true);
                        })
                      
                        .Timeouts(x => x.StoreInSqlServer(settings.ConnectionStrings.RebusContext, "Timeouts"))
                        .Routing(r => r.TypeBased()
                                                    .Map<VerifyNID>(EndPointQueue)
                                                    .Map<ErrorOccurred>(ErrorQueueName)
                                                    ));

//Some Code was removed for the sake of clarity

Amour Rashid
  • 290
  • 3
  • 11
  • Could you maybe post some more information about what you are doing? E.g. show how you configure Rebus, etc. – mookid8000 Nov 15 '20 at 10:48
  • Thanks. I have added code showing how rebus configuration is done in my ConfigureServices method – Amour Rashid Nov 16 '20 at 09:46
  • What does it look like in the RabbitMQ console after it has been running for a while? Do you have a very long list of connections then? – mookid8000 Nov 22 '20 at 20:51

0 Answers0