RabbitMQ - 大量的开放渠道

时间:2015-10-21 21:16:02

标签: c# rabbitmq

我们在生产者和消费者方面都遇到了RabbitMQ的问题,随着时间的推移创建了大量的渠道并且从未关闭过。

我们的IConnection Ninjected使用InSingletonScope,我们有一个生产者可以立即处理模型。

有关为何可能发生这种情况的任何见解?

enter image description here

连接代码:

    Bind<IConnection>()
        .ToMethod(ctx =>
                  {
                      var factory = new ConnectionFactory
                                    {
                                        Uri = ConnectionString,
                                        RequestedHeartbeat = 15,
                                        //every N seconds the server will send a heartbeat.  If the connection does not receive a heartbeat within
                                        //N*2 then the connection is considered dead.
                                        //suggested from http://public.hudl.com/bits/archives/2013/11/11/c-rabbitmq-happy-servers/
                                        AutomaticRecoveryEnabled = true
                                    };

                      return factory.CreateConnection();
                  })
        .InSingletonScope();

发布商代码:

 public void Publish(string exchangeName, string routingKey, IBasicProperties basicProperties, byte[] messageBytes)
    {
        using (var model = _rabbitConnection.CreateModel())
        {
            model.BasicPublish(exchangeName, routingKey, basicProperties, messageBytes);
        }            
    }

Rabbit版本:3.5.1

C#RabbitMQ.Client:3.5.2

1 个答案:

答案 0 :(得分:1)

这似乎是在C#RabbitMQ.Client 3.5.4

上修复的

https://github.com/rabbitmq/rabbitmq-dotnet-client/issues/109