public Task Initialize(RabbitMQChannel channel)
        => Task.Run(() => {
            var model = channel.Model;

            var consumer       = new EventingBasicConsumer(model);
            consumer.Received += (_, ea)
                                 => deliveryHandler.Handle(channel, ea)
                                 .GetAwaiter()
                                 .GetResult();

            model.BasicConsume(
                queue: queue,
                autoAck: acknowledgeMode == AcknowledgeMode.Automatic,
                consumer: consumer
                );
        });
Beispiel #2
0
        public Task Initialize(RabbitMQChannel channel)
        => Task.Run(() => {
            var model = channel.Model;

            var queueName = model.QueueDeclare().QueueName;

            model.QueueBind(
                queue: queueName,
                exchange: exchange,
                routingKey: routingKey
                );

            var consumer       = new EventingBasicConsumer(model);
            consumer.Received += (_, ea)
                                 => deliveryHandler.Handle(channel, ea)
                                 .GetAwaiter()
                                 .GetResult();

            model.BasicConsume(
                queue: queueName,
                autoAck: acknowledgeMode == AcknowledgeMode.Automatic,
                consumer: consumer
                );
        });