/// <summary> /// Initializes a new instance of the Worker class. /// </summary> /// <param name="queue">target Azure storage queue</param> /// <param name="visibleTimeout">message visible timeout</param> /// <param name="messageHandler">message handler</param> /// <param name="invalidQueueHandler">handle invalid queue</param> public Worker(CloudQueue queue, TimeSpan visibleTimeout, MessageHandler messageHandler, InvalidQueueHandler invalidQueueHandler) { this.queue = queue; this.visibleTimeout = visibleTimeout; this.messageHandler = messageHandler; this.invalidQueueHandler = invalidQueueHandler; // do not start the timer here this.timer = new Timer(this.InternalBeginGetMessages, null, Timeout.Infinite, Timeout.Infinite); }
/// <summary> /// Initializes a new instance of the MessageRetriever class. /// </summary> /// <param name="queue">target Azure storage queue</param> /// <param name="concurrency">concurrency for getting messages</param> /// <param name="visibleTimeout">message visible timeout</param> /// <param name="messageHandler">message handler</param> /// <param name="invalidQueueHandler">handle invalid queue</param> public MessageRetriever(CloudQueue queue, int concurrency, TimeSpan visibleTimeout, MessageHandler messageHandler, InvalidQueueHandler invalidQueueHandler) { this.queueName = queue.Name; this.invalidQueueHandler = invalidQueueHandler; this.workers = new Worker[concurrency]; for (int i = 0; i < this.workers.Length; i++) { this.workers[i] = new Worker(queue, visibleTimeout, messageHandler, this.HandleInvalidQueue); } }