public void Start(IProcessor processor, string queue)
        {
            if (!string.IsNullOrEmpty(ConsumerTag))
            {
                throw new InvalidOperationException("Consumer já iniciado.");
            }

            if (string.IsNullOrEmpty(queue))
            {
                throw new ArgumentNullException("queue", "Nome da fila não informado");
            }

            manager.EnsureQueue(queue);
            channel.BasicQos(0, 1, false);

            var consumer = new EventingBasicConsumer(channel);

            consumer.Received += (channel, args) => OnMessageReceived(processor, queue, args);

            ConsumerTag = channel.BasicConsume(
                queue: queue,
                autoAck: false,
                consumer: consumer
                );
        }
Beispiel #2
0
        private void PublishMessage(IMessage message, string destination, bool forceDestination)
        {
            destination = GetDestination(message, destination, forceDestination);
            _manager.EnsureQueue(destination);
            var messageProperties = GetBasicMessageProperties(message);
            var body = _serializer.Serialize(message, Encoding.UTF8);

            _channel.BasicPublish(string.Empty, destination, false, messageProperties, body);
        }
Beispiel #3
0
        public void Start(IProcessor processor, string queue)
        {
            ValidateConsumerStarted();
            ValidateQueueName(queue);
            _manager.EnsureQueue(queue);
            _channel.BasicQos(0, 1, false);
            var consumer = new EventingBasicConsumer(_channel);

            consumer.Received += (channel, args) => OnMessageReceived(processor, queue, args);
            ConsumerTag        = _channel.BasicConsume(queue, false, consumer);
        }