/// <summary> /// Request a metadata refresh from the cluster. /// </summary> /// <returns></returns> private async Task EnsureHasRoutingTable() { RoutingTableRequired(); try { var timeout = TimeSpan.FromMilliseconds(_configuration.ClientRequestTimeoutMs); var taskFetchingMetadata = _cluster.RequireNewRoutingTable(); // We are going to wait for either the task to finish, or the timeout. // This task is blocking the entire (producer) driver, so we can not allow it to run a long // time. if (await(Task.WhenAny(taskFetchingMetadata, Task.Delay(timeout))) == taskFetchingMetadata) { // The task finished ChangeRoutingTable(taskFetchingMetadata.Result); } else { // The Timeout finished first _cluster.Logger.LogError( $"Could not get routing table! The node we queried took more than {timeout.TotalSeconds} seconds to answer."); } } catch (Exception ex) { _cluster.Logger.LogError("Could not get routing table! The Kafka cluster is probably having problems answering requests. Exception was: " + ex); } }
/// <summary> /// Request a metadata refresh from the cluster. /// </summary> /// <returns></returns> private async Task EnsureHasRoutingTable() { RoutingTableRequired(); try { ChangeRoutingTable(await _cluster.RequireNewRoutingTable()); } catch (Exception ex) { _cluster.Logger.LogError("Could not get routing table! The Kafka cluster is probably having problems answering requests. Exception was: " + ex); } }
/// <summary> /// Request a metadata refresh from the cluster. /// </summary> /// <returns></returns> private async Task EnsureHasRoutingTable() { RoutingTableRequired(); bool hasError = false; try { ChangeRoutingTable(await _cluster.RequireNewRoutingTable()); } catch { hasError = true; } if (hasError) { await Task.Delay(_resolution /* == 1000 * (_resolution / 1000) == */); } }