Example #1
0
        public async Task OnScaleUpCosmosDbCollection_SmokeTestSucceeds()
        {
            OnScaleUpCosmosDbCollection onScaleUpCosmosDbCollection = new OnScaleUpCosmosDbCollection(_logger,
                                                                                                      _cosmosDbScalingService,
                                                                                                      Services.BuildServiceProvider().GetRequiredService <IMessengerService>(),
                                                                                                      _userProfileProvider,
                                                                                                      IsDevelopment);

            SmokeResponse response = await RunSmokeTest(ServiceBusConstants.TopicSubscribers.ScaleUpCosmosdbCollection,
                                                        async(Message smokeResponse) => await onScaleUpCosmosDbCollection.Run(smokeResponse),
                                                        ServiceBusConstants.TopicNames.JobNotifications);

            response
            .Should()
            .NotBeNull();
        }
Example #2
0
        public static async Task OnJobNotification(
            [QueueTrigger(ServiceBusConstants.TopicNames.JobNotifications, Connection = "AzureConnectionString")] string item,
            [SignalR(HubName = JobConstants.NotificationsHubName)] IAsyncCollector <SignalRMessage> signalRMessages,
            ILogger logger)
        {
            Message message = Helpers.ConvertToMessage <JobNotification>(item);

            JobNotification jobNotification = message.GetPayloadAsInstanceOf <JobNotification>();

            try
            {
                if (jobNotification.CompletionStatus == CompletionStatus.Succeeded && jobNotification.JobType == JobConstants.DefinitionNames.CreateInstructGenerateAggregationsAllocationJob)
                {
                    using (IServiceScope scope = Functions.Calcs.Startup.RegisterComponents(new ServiceCollection()).CreateScope())
                    {
                        OnCalculationAggregationsJobCompleted function = scope.ServiceProvider.GetService <OnCalculationAggregationsJobCompleted>();

                        await function.Run(message);
                    }
                }
                else
                {
                    using (IServiceScope scope = Jobs.Startup.RegisterComponents(new ServiceCollection()).CreateScope())
                    {
                        Jobs.ServiceBus.OnJobNotification function = scope.ServiceProvider.GetService <Jobs.ServiceBus.OnJobNotification>();

                        await function.Run(message);
                    }
                }
            }
            catch (Exception ex)
            {
                logger.LogError(ex, "Error while executing Jobs Notification Event");
            }


            using (IServiceScope scope = Functions.Notifications.Startup.RegisterComponents(new ServiceCollection()).CreateScope())
            {
                try
                {
                    Notifications.OnNotificationEventTrigger function = scope.ServiceProvider.GetService <Notifications.OnNotificationEventTrigger>();

                    await function.Run(message, signalRMessages);
                }
                catch (Exception ex)
                {
                    logger.LogError(ex, "Error while executing Notification Event");
                }
            }

            using (IServiceScope scope = Functions.CosmosDbScaling.Startup.RegisterComponents(new ServiceCollection()).CreateScope())
            {
                try
                {
                    OnScaleUpCosmosDbCollection function = scope.ServiceProvider.GetService <OnScaleUpCosmosDbCollection>();

                    await function.Run(message);
                }
                catch (Exception ex)
                {
                    logger.LogError(ex, "Error while executing Scale Up Event");
                }

                logger.LogInformation($"C# Queue trigger function processed: {item}");
            }
        }