Beispiel #1
0
        public IDisposable StartConsuming()
        {
            this._internalConsumer = this._internalConsumerFactory.CreateConsumer();

            this._internalConsumer.Cancelled += consumer => Dispose();

            this._internalConsumer.StartConsuming(
                this._connection,
                this._queue,
                this._onMessage,
                this._configuration);

            return(new ConsumerCancellation(Dispose));
        }
        private void StartConsumingInternal()
        {
            if (this._disposed)
            {
                return;
            }
            if (!this._connection.IsConnected)
            {
                return;
            }

            InternalConsumer internalConsumer = this._internalConsumerFactory.CreateConsumer();

            this._internalConsumers.TryAdd(internalConsumer, null);

            internalConsumer.Cancelled += consumer => this.Dispose();

            internalConsumer.StartConsuming(this._connection, this._queue, this._onMessage, this._configuration);
        }