2016-07-14 4 views
0

RabbitMQ ConnectionFactory의 AutomaticRecoveryEnabled 속성을 테스트하려고합니다. 로컬 VM에서 RabbitMQ 인스턴스에 연결 중이며 클라이언트에서 메시지를 루프에 게시하고 있습니다. 문제는 내가 의도적으로 연결을 끊으면 클라이언트는 단지 영원히 기다리고 시간을 초과하지 않는다는 것입니다. 타임 아웃 값은 어떻게 설정합니까? RequestedConnectionTimeout은 효과가없는 것으로 보입니다.RabbitMQ .NET 클라이언트 및 연결 시간 초과

public bool Publish(string routingKey, byte[] body) 
{ 
    try 
    { 
     using (var channel = _connection.CreateModel()) 
     { 
      var basicProps = new BasicProperties 
      { 
       Persistent = true, 
      }; 

      channel.ExchangeDeclare(_exchange, _exchangeType); 
      channel.BasicPublish(_exchange, routingKey, basicProps, body); 

      return true; 
     } 
    } 
    catch (Exception e) 
    { 
     _logger.Log(e); 
    } 

    return false; 
} 

연결 및 연결 팩토리 :

// Client is a wrapper around the RabbitMQ client 
for (var i = 0; i < 1000; ++i) 
{ 
    // Publish sequentially numbered messages 
    client.Publish("routingkey", GetContent(i))); 
    Thread.Sleep(100); 
} 

다음은 래퍼 안에 방법을 게시 :

나는 RabbitMQ 클라이언트를 사용하고 3.5.4

초보 루프 게시

_connectionFactory = new ConnectionFactory 
{ 
    UserName = _userName, 
    Password = _password, 
    HostName = _hostName, 
    Port = _port, 
    Protocol = Protocols.DefaultProtocol, 
    VirtualHost = _virtualHost, 

    // Doesn't seem to have any effect on broken connections 
    RequestedConnectionTimeout = 2000, 

    // The behaviour appears to be the same with or without these included 
    // AutomaticRecoveryEnabled = true, 
    // NetworkRecoveryInterval = TimeSpan.FromSeconds(10), 
}; 

_connection = _connectionFactory.CreateConnection(); 

답변

0

이것은 3.5.4 버전의 버그입니다. 버전 3.6.3은 무기한 대기하지 않습니다.