示例#1
0
        public void ForCreatesHandlerForGivenQueue()
        {
            var mockQueue = new Mock <IAzureQueue <MessageStub> >();

            var queueHandler = BatchMultipleQueueHandler.For(mockQueue.Object, 1);

            Assert.IsInstanceOfType(queueHandler, typeof(BatchMultipleQueueHandler <MessageStub>));
        }
        public override void Run()
        {
            //// The time interval for checking the queues have to be tuned depending on the scenario and the expected workload
            var standardQueue = this.container.Resolve <IAzureQueue <SurveyAnswerStoredMessage> >(SubscriptionKind.Standard.ToString());
            var premiumQueue  = this.container.Resolve <IAzureQueue <SurveyAnswerStoredMessage> >(SubscriptionKind.Premium.ToString());

            BatchMultipleQueueHandler
            .For(premiumQueue, 8)
            .AndFor(standardQueue, 8)
            .Every(TimeSpan.FromSeconds(10))
            .Do(this.container.Resolve <UpdatingSurveyResultsSummaryCommand>());

            QueueHandler
            .For(this.container.Resolve <IAzureQueue <SurveyTransferMessage> >())
            .Every(TimeSpan.FromSeconds(5))
            .Do(this.container.Resolve <TransferSurveysToSqlAzureCommand>());

            while (true)
            {
                Thread.Sleep(TimeSpan.FromSeconds(5));
            }
        }
示例#3
0
        /// <summary>
        /// This is the main entry point for your service instance.
        /// </summary>
        /// <param name="cancellationToken">Canceled when Service Fabric needs to shut down this service instance.</param>
        protected override async Task RunAsync(CancellationToken cancellationToken)
        {
            // The time interval for checking the queues have to be tuned depending on the scenario and the expected workload
            var standardQueue = _container.ResolveNamed <IAzureQueue <SurveyAnswerStoredMessage> >(SubscriptionKind.Standard.ToString());
            var premiumQueue  = _container.ResolveNamed <IAzureQueue <SurveyAnswerStoredMessage> >(SubscriptionKind.Premium.ToString());

            BatchMultipleQueueHandler
            .For(premiumQueue, 8)
            .AndFor(standardQueue, 8)
            .Every(TimeSpan.FromSeconds(10))
            .Do(_container.Resolve <UpdatingSurveyResultsSummaryCommand>(), cancellationToken);

            QueueHandler
            .For(_container.Resolve <IAzureQueue <SurveyTransferMessage> >())
            .Every(TimeSpan.FromSeconds(5))
            .Do(_container.Resolve <TransferSurveysToSqlAzureCommand>(), cancellationToken);

            while (true)
            {
                cancellationToken.ThrowIfCancellationRequested();
                ServiceEventSource.Current.ServiceMessage(this.Context, "Polling the queue...");
                await Task.Delay(TimeSpan.FromSeconds(1), cancellationToken);
            }
        }
示例#4
0
 public void ForThrowsWhenQueueIsNull()
 {
     BatchMultipleQueueHandler.For(default(IAzureQueue <MessageStub>), 1);
 }