public async Task Handle(SendLiveSourceNotification notification, CancellationToken cancellationToken)
        {
            var syncMessage = new LiveSyncMessage
            {
                ConnectorType        = notification.ConnectorType,
                SportType            = notification.SportType,
                When                 = notification.When,
                FinishTime           = notification.FinishTime,
                PollingIntervalInSec = notification.PollingIntervalInSec,
                CompetitionUniqueId  = notification.CompetitionUniqueId,
                StartTime            = notification.StartTime,
                Uri = notification.Uri
            };

            var brokeredMessage = syncMessage.ToBrokeredMessage();
            await queueClient.Client.SendAsync(brokeredMessage);
        }
Example #2
0
        public async Task LiveDataFunctionServiceBus(
            [ServiceBusTrigger("%ServiceBusQueueName%", Connection = "ServiceBusConnectionString")] LiveSyncMessage message,
            [DurableClient] IDurableOrchestrationClient client,
            ILogger log)
        {
            //todo: UniqueId might be used here if we need some kind of identification, but should include connectorType then.
            if (message.Uri != null)
            {
                var instanceId = message.Uri.ToBase64OrNull();

                var existingInstance = await client.GetStatusAsync(instanceId);

                if (existingInstance == null ||
                    existingInstance.RuntimeStatus == OrchestrationRuntimeStatus.Completed ||
                    existingInstance.RuntimeStatus == OrchestrationRuntimeStatus.Failed ||
                    existingInstance.RuntimeStatus == OrchestrationRuntimeStatus.Terminated)
                {
                    log.LogInformation($"{nameof(LiveDataFunction)} was triggered.");
                    await client.StartNewAsync("ScheduledLiveMonitoring", instanceId, message);
                }
            }
        }