public Task BindQueueAsync(string queue, string exchange, string routingKey, IDictionary <string, object> arguments) { if (string.Equals(exchange, string.Empty)) { /* * "The default exchange is implicitly bound to every queue, * with a routing key equal to the queue name. It it not possible * to explicitly bind to, or unbind from the default exchange." */ return(_completed); } var bindKey = CreateBindKey(queue, exchange, routingKey, arguments); if (_queueBinds.Contains(bindKey)) { return(_completed); } var scheduled = new ScheduledBindQueueTask { Queue = queue, Exchange = exchange, RoutingKey = routingKey, Arguments = arguments }; _topologyTasks.Enqueue(scheduled); EnsureWorker(); return(scheduled.TaskCompletionSource.Task); }
private void BindQueueToExchange(ScheduledBindQueueTask bind) { string bindKey = CreateBindKey(bind); if (_queueBinds.Contains(bindKey)) { return; } _logger.Info("Binding queue {queueName} to exchange {exchangeName} with routing key {routingKey}", bind.Queue, bind.Exchange, bind.RoutingKey); var channel = GetOrCreateChannel(); channel.QueueBind( queue: bind.Queue, exchange: bind.Exchange, routingKey: bind.RoutingKey, arguments: bind.Arguments ); _queueBinds.Add(bindKey); }
public Task BindQueueAsync(QueueConfiguration queue, ExchangeConfiguration exchange, string routingKey) { if (exchange.IsDefaultExchange()) { return(_completed); } var bindKey = $"{queue.FullQueueName}_{exchange.ExchangeName}_{routingKey}"; if (_queueBinds.Contains(bindKey)) { return(_completed); } var scheduled = new ScheduledBindQueueTask { Queue = queue, Exchange = exchange, RoutingKey = routingKey }; _topologyTasks.Enqueue(scheduled); EnsureWorker(); return(scheduled.TaskCompletionSource.Task); }
private void BindQueueToExchange(ScheduledBindQueueTask bind) { var bindKey = $"{bind.Queue.FullQueueName}_{bind.Exchange.ExchangeName}_{bind.RoutingKey}"; if (_queueBinds.Contains(bindKey)) { return; } DeclareQueue(bind.Queue); DeclareExchange(bind.Exchange); _logger.LogInformation($"绑定队列'{bind.Queue.FullQueueName}'到交换器'{bind.Exchange.ExchangeName}'且路由值为'{bind.RoutingKey}'"); var channel = GetOrCreateChannel(); channel.QueueBind( queue: bind.Queue.FullQueueName, exchange: bind.Exchange.ExchangeName, routingKey: bind.RoutingKey ); _queueBinds.Add(bindKey); }
public Task BindQueueAsync(QueueConfiguration queue, ExchangeConfiguration exchange, string routingKey) { if (exchange.IsDefaultExchange()) { /* * "The default exchange is implicitly bound to every queue, * with a routing key equal to the queue name. It it not possible * to explicitly bind to, or unbind from the default exchange." */ return(_completed); } if (queue.IsDirectReplyTo()) { /* * "Consume from the pseudo-queue amq.rabbitmq.reply-to in no-ack mode. There is no need to * declare this "queue" first, although the client can do so if it wants." * - https://www.rabbitmq.com/direct-reply-to.html */ return(_completed); } var bindKey = $"{queue.FullQueueName}_{exchange.ExchangeName}_{routingKey}"; if (_queueBinds.Contains(bindKey)) { return(_completed); } var scheduled = new ScheduledBindQueueTask { Queue = queue, Exchange = exchange, RoutingKey = routingKey }; _topologyTasks.Enqueue(scheduled); EnsureWorker(); return(scheduled.TaskCompletionSource.Task); }
public Task BindQueueAsync(QueueConfiguration queue, ExchangeConfiguration exchange, string routingKey) { if (exchange.IsDefaultExchange()) { /* "The default exchange is implicitly bound to every queue, with a routing key equal to the queue name. It it not possible to explicitly bind to, or unbind from the default exchange." */ return _completed; } if (queue.IsDirectReplyTo()) { /* "Consume from the pseudo-queue amq.rabbitmq.reply-to in no-ack mode. There is no need to declare this "queue" first, although the client can do so if it wants." - https://www.rabbitmq.com/direct-reply-to.html */ return _completed; } var bindKey = $"{queue.FullQueueName}_{exchange.ExchangeName}_{routingKey}"; if (_queueBinds.Contains(bindKey)) { return _completed; } var scheduled = new ScheduledBindQueueTask { Queue = queue, Exchange = exchange, RoutingKey = routingKey }; _topologyTasks.Enqueue(scheduled); EnsureWorker(); return scheduled.TaskCompletionSource.Task; }
private void BindQueueToExchange(ScheduledBindQueueTask bind) { var bindKey = $"{bind.Queue.FullQueueName}_{bind.Exchange.ExchangeName}_{bind.RoutingKey}"; if (_queueBinds.Contains(bindKey)) { return; } DeclareQueue(bind.Queue); DeclareExchange(bind.Exchange); _logger.LogInformation($"Binding queue '{bind.Queue.FullQueueName}' to exchange '{bind.Exchange.ExchangeName}' with routing key '{bind.RoutingKey}'"); var channel = GetOrCreateChannel(); channel.QueueBind( queue: bind.Queue.FullQueueName, exchange: bind.Exchange.ExchangeName, routingKey: bind.RoutingKey ); _queueBinds.Add(bindKey); }
private static string CreateBindKey(ScheduledBindQueueTask bind) { return(CreateBindKey(bind.Queue, bind.Exchange, bind.RoutingKey, bind.Arguments)); }