private RabbitMQConsumerOptions <string> GetConfig(bool declareQueue = true)
 {
     return(new()
     {
         Host = "someHost",
         Port = 12345,
         User = "******",
         Password = "******",
         VirtualHost = "vHost",
         PrefetchCount = DefaultPrefetchCount,
         DeclareQueue = declareQueue,
         RequestedHeartbeat = TimeSpan.FromSeconds(111),
         Queue = new RabbitMQQueueOptions
         {
             Name = "qName",
             Durable = true,
             AutoDelete = false,
             Bindings = new[]
             {
                 new RabbitMQBindingOptions
                 {
                     Exchange = "someExchange",
                     RoutingKey = "routingKey",
                     Arguments = new Dictionary <string, object>()
                 },
                 new RabbitMQBindingOptions
                 {
                     Exchange = "someOtherExchange",
                     RoutingKey = "someOtherRoutingKey",
                     Arguments = new Dictionary <string, object>()
                 }
             }
         }
     });
 }
Пример #2
0
 private void ThrowIfInvalid(RabbitMQQueueOptions queueOptions)
 {
     if (queueOptions == null)
     {
         throw new ArgumentException(nameof(queueOptions));
     }
     if (string.IsNullOrWhiteSpace(queueOptions.Name))
     {
         throw new ArgumentException(nameof(queueOptions.Name));
     }
     if (queueOptions.Bindings == null)
     {
         return;
     }
     if (!queueOptions.Bindings.Any())
     {
         return;
     }
     foreach (var binding in queueOptions.Bindings)
     {
         if (string.IsNullOrWhiteSpace(binding.Exchange))
         {
             throw new ArgumentException(nameof(binding.Exchange));
         }
         if (string.IsNullOrWhiteSpace(binding.RoutingKey))
         {
             throw new ArgumentException(nameof(binding.RoutingKey));
         }
     }
 }
    private static IDictionary <string, object> GetExpectedArgumentsFromConfig(RabbitMQQueueOptions options)
    {
        var expectedArguments = options.Arguments.ToDictionary(t => t.Key, t => t.Value);

        expectedArguments.Add("x-max-priority", options.MaxPriority);
        expectedArguments.Add("x-max-length", options.MaxLength);
        expectedArguments.Add("x-max-length-bytes", options.MaxLengthBytes);
        expectedArguments.Add("x-message-ttl", options.MessageTtl);
        return(expectedArguments);
    }
 private RabbitMQConsumerOptions <string> GetConsumerConfig(string host, string user, string password,
                                                            string virtualHost,
                                                            string name, string exchange, string routingKey)
 {
     return(new()
     {
         Host = host,
         VirtualHost = virtualHost,
         User = user,
         Password = password,
         Queue = new RabbitMQQueueOptions
         {
             Name = name,
             Bindings = new[]
             {
                 new RabbitMQBindingOptions
                 {
                     Exchange = exchange,
                     RoutingKey = routingKey
                 }
             }
         }
     });
 }
 public RabbitMQQueue(RabbitMQQueueOptions options, string name)
 {
     this.options = options;
     Name         = name;
 }