public void BasicQos(RabbitMQConsumerDeclaration declaration)
 {
     lock (@lock)
     {
         // PrefetchSize != 0 is not implemented for now
         channel.BasicQos(0, declaration.PrefetchCount, declaration.Global);
     }
 }
예제 #2
0
 public RabbitMQConsumer(
     IModel channel,
     RabbitMQOptions options,
     IServiceProvider serviceProvider,
     RabbitMQConsumerDeclaration declaration,
     CancellationToken cancellationToken) : base(channel)
 {
     this.options           = options;
     this.declaration       = declaration;
     this.cancellationToken = cancellationToken;
     this.serviceProvider   = serviceProvider;
 }
예제 #3
0
        public static IRabbitMQConsumerBuilder <TPayload> AddConsumer <TPayload>(
            this IRabbitMQConnectionBuilder connection,
            params IRabbitMQQueueBuilder <TPayload>[] queues)
        {
            var declaration = new RabbitMQConsumerDeclaration(
                typeof(TPayload),
                connection.ConnectionDeclaration,
                queues.Select(queue => queue.Declaration).ToArray());

            connection.Services
            .Configure <RabbitMQOptions>(
                options => options.ConsumerDeclarations.Add(declaration));

            return(new RabbitMQConsumerBuilder <TPayload>(declaration));
        }
 // Consumers
 public void BasicConsume(
     IServiceProvider serviceProvider,
     RabbitMQOptions options,
     RabbitMQQueueDeclaration queue,
     RabbitMQConsumerDeclaration declaration,
     CancellationToken cancellationToken)
 {
     lock (@lock)
     {
         for (var index = 0; index < declaration.Count; index++)
         {
             channel.BasicConsume(
                 queue: queue.Name,
                 autoAck: declaration.AutoAck,
                 consumerTag: declaration.Tag is null
                                                 ? string.Empty
                                                 : $"{declaration.Tag}_{index}",
                 noLocal: declaration.NoLocal,
                 exclusive: declaration.Exclusive,
                 arguments: declaration.Arguments,
                 consumer: new RabbitMQConsumer(channel, options, serviceProvider, declaration, cancellationToken));
         }
     }
 }