/// <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); } } }); }
public void Pause() { TraceUtils.TraceInfo("MessageSender", "Pause", "Pause the message sender."); this.workers.AsParallel <Worker>().ForAll <Worker>( (w) => { w.Pause(); }); }
/// <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(); }); }
/// <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(); }); }
/// <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(); }); } }
/// <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; } } }
public void Pause() { TraceUtils.TraceInfo("MessageSender.Worker", "Pause", "Pause the message sender worker."); this.stop = true; }