Ejemplo n.º 1
0
        public async static Task ProcessQueueMessage()
        {
            if (string.IsNullOrEmpty(Settings.AAdAppId) || string.IsNullOrEmpty(Settings.AAdAppSecret))
            {
                // Will throw exception if the connector is not configured.
                GetConfigurationSettingFomStorge().Wait();
            }

            queueProvider       = new AzureStorageQueueProvider(Settings.StorageAccountConnectionString, Settings.QueueName);
            azureTableProvider  = new AzureTableProvider(Settings.StorageAccountConnectionString);
            pageJobMappingTable = await azureTableProvider.EnsureTableExistAsync(Settings.PageJobMappingTableName);

            while (true)
            {
                try
                {
                    CloudQueueMessage queueMessage = queueProvider.GetMessage(queueVisibilityTimeOutInSec);

                    if (queueMessage != null)
                    {
                        await ProcessMessage(queueMessage, httpClient, pageJobMappingTable);

                        // Delete the message
                        queueProvider.DeleteMessage(queueMessage);
                    }
                    else
                    {
                        await Task.Delay(sleepTime);
                    }
                }
                catch (Exception ex)
                {
                    // If ProcessMessage throws an exception, it will reappear in queue after visibility timeout
                    Trace.TraceError($"Processing Failed in ProcessQueueMessage. Exception: {ex.Message}, {ex.StackTrace}");
                }
            }
        }
 public DataIngestionController()
 {
     this.queueProvider = new AzureStorageQueueProvider(Settings.StorageAccountConnectionString, Settings.QueueName);
     this.azureTableProviderInstance = new AzureTableProvider(Settings.StorageAccountConnectionString);
 }