示例#1
0
 private void TryCreateExchangeAndQueue()
 {
     if (!_persistentConnection.IsConnected)
     {
         _persistentConnection.TryConnect();
     }
     using (var channel = _persistentConnection.CreateModel())
     {
         ExchangeDeclare.Declare(channel);
         QueueDeclare.Declare(channel);
     }
 }
示例#2
0
 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);
 }