private void TryCreateExchangeAndQueue() { if (!_persistentConnection.IsConnected) { _persistentConnection.TryConnect(); } using (var channel = _persistentConnection.CreateModel()) { ExchangeDeclare.Declare(channel); QueueDeclare.Declare(channel); } }
public Task BindAsync(string routingKey) { if (!_persistentConnection.IsConnected) { _persistentConnection.TryConnect(); } using (var channel = _persistentConnection.CreateModel()) { ExchangeDeclare.Declare(channel); QueueDeclare.Declare(channel); channel.QueueBind(queue: QueueDeclare.QueueName, exchange: ExchangeDeclare.ExchangeName, routingKey: routingKey); BindingQueueRoutingKeys.TryAdd(routingKey, QueueDeclare.QueueName); } return(Task.CompletedTask); }