예제 #1
0
        /// <summary>
        /// Handle received message
        /// </summary>
        /// <param name="t">received message object</param>
        private void ConcurrentHandle(T t)
        {
            this.semSubscription.Wait(TimeSpan.FromMinutes(Constant.DataProxyOperationTimeoutInMinutes));

            ThreadPool.QueueUserWorkItem(
                delegate(object state)
            {
                try
                {
                    this.handler(t);
                }
                catch (Exception ex)
                {
                    // message handler should never throw exception.
                    TraceUtils.TraceInfo(
                        "AzureQueueListener", "ConcurrentHandle", "Exception {0} while handle message {1}", ex, t);
                }
                finally
                {
                    try
                    {
                        this.semSubscription.Release();
                    }
                    catch (Exception ex)
                    {
                        // swallow any exception including ObjectDisposedException
                        TraceUtils.TraceInfo(
                            "AzureQueueListener", "ConcurrentHandle", "Exception {0} while release semSubscription", ex);
                    }
                }
            });
        }
예제 #2
0
        public void Pause()
        {
            TraceUtils.TraceInfo("MessageSender", "Pause", "Pause the message sender.");

            this.workers.AsParallel <Worker>().ForAll <Worker>(
                (w) =>
            {
                w.Pause();
            });
        }
예제 #3
0
        /// <summary>
        /// Start the sender workers.
        /// </summary>
        public void Start()
        {
            TraceUtils.TraceInfo("MessageSender", "Start", "Start the message sender.");

            this.workers.AsParallel <Worker>().ForAll <Worker>(
                (w) =>
            {
                w.Start();
            });
        }
예제 #4
0
        /// <summary>
        /// Start the message retriever.
        /// </summary>
        public void Start()
        {
            TraceUtils.TraceInfo(
                "MessageRetriever", "Start", "Start {0} workers, queue {1}", this.workers.Length, this.queueName);

            this.workers.AsParallel <Worker>().ForAll <Worker>(
                (w) =>
            {
                w.Start();
            });
        }
예제 #5
0
        /// <summary>
        /// Dispose the object.
        /// </summary>
        /// <param name="disposing">disposing flag</param>
        protected override void Dispose(bool disposing)
        {
            base.Dispose(disposing);

            TraceUtils.TraceInfo(
                "MessageRetriever", "Dispose", "Queue {0}, disposing is {1}", this.queueName, disposing);

            if (disposing)
            {
                this.workers.AsParallel <Worker>().ForAll <Worker>(
                    (w) =>
                {
                    w.Close();
                });
            }
        }
예제 #6
0
            /// <summary>
            /// Start the worker.
            /// </summary>
            public void Start()
            {
                TraceUtils.TraceInfo("MessageSender.Worker", "Start", "Start the message sender worker.");

                this.stop        = false;
                this.sleepPeriod = 0;

                // start the run if timer stopped
                lock (this.timerStopLock)
                {
                    if (this.timerStopped)
                    {
                        this.timerStopped = false;
                        // trigger the timer
                        this.timer.Change(0, Timeout.Infinite);
                        this.sleepPeriod = MinSleepTime;
                    }
                }
            }
예제 #7
0
            public void Pause()
            {
                TraceUtils.TraceInfo("MessageSender.Worker", "Pause", "Pause the message sender worker.");

                this.stop = true;
            }