示例#1
0
        private static string ProcessVideo(string videoUrl)
        {
            SkiVideoProcessor processor = new SkiVideoProcessor();
            string            url       = processor.Process(videoUrl);

            return(url);
        }
示例#2
0
        async Task ProcessMessagesAsync(Message message, CancellationToken token)
        {
            if (_queueClient.IsClosedOrClosing)
            {
                Logger.Log("Queue is closing, abandoning message.");
                await _queueClient.AbandonAsync(message.SystemProperties.LockToken);

                return;
            }

            string videoUrl = "";

            try
            {
                // Process the message.
                Logger.Log($"Received message: SequenceNumber:{message.SystemProperties.SequenceNumber} Body:{Encoding.UTF8.GetString(message.Body)}");

                string json = Encoding.UTF8.GetString(message.Body);
                videoUrl = QueueMessageParser.GetUrl(json);
                Logger.Log($"Received this videoUrl: {videoUrl}");

                if (videoUrl.EndsWith("test.MP4"))
                {
                    throw new ApplicationException("Something broke, fail safe for testing exceptions!");
                }

                SkiVideoProcessor processor = new SkiVideoProcessor(videoUrl);
                await processor.ProcessAsync();

                await _queueClient.CompleteAsync(message.SystemProperties.LockToken);
            }
            catch (Exception e)
            {
                if (message.SystemProperties.DeliveryCount <= 2)
                {
                    Logger.Log($"Abandoned message.", e);
                    // abandon and allow another to try in case of transient errors
                    await _queueClient.AbandonAsync(message.SystemProperties.LockToken);
                }
                else
                {
                    Logger.Log($"Dead lettering message.", e);
                    await _queueClient.DeadLetterAsync(message.SystemProperties.LockToken,
                                                       e.Message, e.InnerException?.Message);
                }
            }
            finally
            {
                Logger.Log($"Message handler completed for {videoUrl}.");
                if (Completed != null)
                {
                    Completed(this, null);
                }
            }
        }
示例#3
0
        private static void ProcessVideo(string videoUrl)
        {
            SkiVideoProcessor processor = new SkiVideoProcessor(videoUrl);

            processor.ProcessAsync().Wait();
        }