Beispiel #1
0
        /// <summary>
        /// Запускает обработку входящих сообщений.
        /// </summary>
        public void StartConsuming()
        {
            if (this.isConsuming)
            {
                return;
            }

            this.logger.InfoFormat("Starting consuming on [{0}].", this.endpoint.ListeningSource);

            this.cancellationTokenSource = new CancellationTokenSource();
            this.ticketTimer             = new RoughTicketTimer(TimeSpan.FromSeconds(1));

            this.workers = Enumerable.Range(
                0,
                (int)this.ReceiverOptions.GetParallelismLevel().Value)
                           .Select(_ => ThreadWorker.StartNew(this.Consume, this.cancellationTokenSource.Token))
                           .ToList();

            this.isConsuming = true;
        }