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 QueueDelete(ILinkQueue queue, bool ifUnused = false, bool ifEmpty = false) { if (queue == null) { throw new ArgumentNullException(nameof(queue)); } await _invoker .InvokeAsync(model => model.QueueDelete(queue.Name, ifUnused, ifEmpty)) .ConfigureAwait(false); _logger.Debug($"Deleted queue \"{queue.Name}\", unused: {ifUnused}, empty: {ifEmpty}"); }
public async Task QueuePurge(ILinkQueue queue) { if (queue == null) { throw new ArgumentNullException(nameof(queue)); } await _invoker .InvokeAsync(model => model.QueuePurge(queue.Name)) .ConfigureAwait(false); _logger.Debug($"Purged queue \"{queue.Name}\""); }
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 { _queue = 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); }