我们在生产者和消费者方面都遇到了RabbitMQ的问题,随着时间的推移创建了大量的渠道并且从未关闭过。
我们的IConnection Ninjected使用InSingletonScope,我们有一个生产者可以立即处理模型。
有关为何可能发生这种情况的任何见解?
连接代码:
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
答案 0 :(得分:1)
这似乎是在C#RabbitMQ.Client 3.5.4
上修复的https://github.com/rabbitmq/rabbitmq-dotnet-client/issues/109