Contour.Transport.RabbitMQ.Internal.RabbitChannel.StartConsuming C# (CSharp) Method

StartConsuming() public method

The start consuming.
public StartConsuming ( IListeningSource listeningSource, bool requireAccept, IBasicConsumer consumer ) : string
listeningSource IListeningSource /// The listening source. ///
requireAccept bool /// The require accept. ///
consumer IBasicConsumer /// The consumer. ///
return string
        public string StartConsuming(IListeningSource listeningSource, bool requireAccept, IBasicConsumer consumer)
        {
            string consumerTag = string.Empty;

            this.SafeNativeInvoke(n => consumerTag = n.BasicConsume(listeningSource.Address, !requireAccept, consumer));

            return consumerTag;
        }

Usage Example

Example #1
0
        private CancellableQueueingConsumer InitializeConsumer(CancellationToken token, out RabbitChannel channel)
        {
            // Opening a new channel may lead to a new connection creation
            channel           = this.connection.OpenChannel(token);
            channel.Shutdown += this.OnChannelShutdown;
            this.channels.Add(channel);

            if (this.ReceiverOptions.GetQoS().HasValue)
            {
                channel.SetQos(
                    this.ReceiverOptions.GetQoS().Value);
            }

            var consumer = channel.BuildCancellableConsumer(token);
            var tag      = channel.StartConsuming(
                this.endpoint.ListeningSource,
                this.ReceiverOptions.IsAcceptRequired(),
                consumer);

            this.logger.Trace(
                $"A consumer tagged [{tag}] has been registered in listener of [{string.Join(",", this.AcceptedLabels)}]");

            return(consumer);
        }