public async Task Bind(ILinkExchange destination, ILinkExchange source, string routingKey = null, IDictionary <string, object> arguments = null) { if (source == null) { throw new ArgumentNullException(nameof(source)); } if (destination == null) { throw new ArgumentNullException(nameof(destination)); } if (routingKey == null) { routingKey = string.Empty; } if (arguments == null) { arguments = new Dictionary <string, object>(); } await _invoker .InvokeAsync(model => model.ExchangeBind(destination.Name, source.Name, routingKey, arguments)) .ConfigureAwait(false); _logger.Debug( $"Bound destination exchange {destination.Name} to source exchange {source.Name} with routing key {routingKey} and arguments: {string.Join(", ", arguments.Select(x => $"{x.Key} = {x.Value}"))}"); }
public async Task Bind(ILinkQueue queue, ILinkExchange exchange, string routingKey = null, IDictionary <string, object> arguments = null) { if (exchange == null) { throw new ArgumentNullException(nameof(exchange)); } if (queue == null) { throw new ArgumentNullException(nameof(queue)); } if (routingKey == null) { routingKey = string.Empty; } if (arguments == null) { arguments = new Dictionary <string, object>(); } await _invoker .InvokeAsync(model => model.QueueBind(queue.Name, exchange.Name, routingKey, arguments)) .ConfigureAwait(false); _logger.Debug( $"Bound queue {queue.Name} to exchange {exchange.Name} with routing key {routingKey} and arguments: {string.Join(", ", arguments.Select(x => $"{x.Key} = {x.Value}"))}"); }
public async Task ExchangeDelete(ILinkExchange exchange, bool ifUnused = false) { if (exchange == null) { throw new ArgumentNullException(nameof(exchange)); } await _invoker .InvokeAsync(model => model.ExchangeDelete(exchange.Name, ifUnused)) .ConfigureAwait(false); _logger.Debug($"Deleted exchange \"{exchange.Name}\", unused: {ifUnused}"); }
private async Task <bool> ConfigureAsync(IModel model, bool retry, CancellationToken cancellation) { if (retry) { try { _logger.Debug($"Retrying in {_configuration.RecoveryInterval.TotalSeconds:0.###}s"); await Task.Delay(_configuration.RecoveryInterval, cancellation) .ConfigureAwait(false); } catch { return(false); } } _logger.Debug("Configuring topology"); try { _exchange = await _topologyRunner .RunAsync(model, cancellation) .ConfigureAwait(false); } catch (Exception ex) { _logger.Warning($"Exception on topology configuration: {ex}"); try { await _configuration.TopologyHandler.ConfigurationError(ex) .ConfigureAwait(false); } catch (Exception handlerException) { _logger.Error($"Exception in topology error handler: {handlerException}"); } return(false); } _logger.Debug("Topology configured"); return(true); }