0

I am currently adding video services to an application using Azure media services and Azure Storage with C# web api. The upload process seems to be working correctly and I can see where the job completes successfully from the admin. console.

However, if I run the application under the debugger I see where messages are being added to the queue for actually processing the videos but I never get any messages in the notification queue. I keep reviewing the code but I don't see anything that appears to be off. Has anyone encountered this before or have any idea of what the problem could be? I am currently testing in debug mode with my connection strings set to UseDevelopmentStorage=true.

// create a NotificationEndPoint queue based on the endPointAddress
string endPointAddress = "queuename";

// setup the notificationEndPoint based on the queue and endPointAddress
this.notificationEndPoint = this._context.NotificationEndPoints.Create(Guid.NewGuid().ToString(), NotificationEndPointType.AzureQueue, endPointAddress);

if (this.notificationEndPoint != null)
{
     job.JobNotificationSubscriptions.AddNew(NotificationJobState.All, this.notificationEndPoint);
     await job.SubmitAsync().ConfigureAwait(false);
      .
      .
      .



Here is the message object:
public class VideoJobNotificationMessage : AzureQueueMessage
{
// MessageVersion is used for version control. 
public string MessageVersion { get; set; }

// Type of the event. Valid values are 
// JobStateChange and NotificationEndpointRegistration.
public string EventType { get; set; }

// ETag is used to help the customer detect if 
// the message is a duplicate of another message previously sent.
public string ETag { get; set; }

// Time of occurrence of the event.
public string TimeStamp { get; set; }

// Collection of values specific to the event.
public IDictionary<string, object> Properties { get; set; }
}
halfer
  • 19,824
  • 17
  • 99
  • 186
user1790300
  • 2,143
  • 10
  • 54
  • 123

1 Answers1

0

Just run verification test ShouldReceiveNotificationsForCompeletedJob from https://github.com/Azure/azure-sdk-for-media-services/blob/dev/test/net/Scenario/JobTests.cs which verifies notifications workflow. Test is passing in US WEST data center.

Please note that job notifications through azure storage queue are not designed to be real time and as you can see there is few minutes delay between messages appears in queue.

Pasting code related to queue creation:

 string endPointAddress = Guid.NewGuid().ToString();
                CloudQueueClient client = CloudStorageAccount.Parse(WindowsAzureMediaServicesTestConfiguration.ClientStorageConnectionString).CreateCloudQueueClient();
                CloudQueue queue = client.GetQueueReference(endPointAddress);
                queue.CreateIfNotExists();
                string endPointName = Guid.NewGuid().ToString();
                INotificationEndPoint notificationEndPoint = _mediaContext.NotificationEndPoints.Create(endPointName, NotificationEndPointType.AzureQueue, endPointAddress);
                Assert.IsNotNull(notificationEndPoint);
 job.JobNotificationSubscriptions.AddNew(NotificationJobState.All, notificationEndPoint);

.......

            job.Submit();

            Assert.IsTrue(job.JobNotificationSubscriptions.Count > 0);

            WaitForJob(job.Id, JobState.Finished, VerifyAllTasksFinished);
            Thread.Sleep((int)TimeSpan.FromMinutes(5).TotalMilliseconds);

            Assert.IsNotNull(queue);
            Assert.IsTrue(queue.Exists());
            IEnumerable<CloudQueueMessage> messages = queue.GetMessages(10);
            Assert.IsTrue(messages.Any());
            Assert.AreEqual(4, messages.Count(), "Expecting to have 4 notifications messages");
George Trifonov
  • 1,971
  • 17
  • 20
  • Should I look to add this file and associated files to my test project? – user1790300 May 11 '15 at 22:33
  • You can simply clone repository. Add your media account details and queue endpoint to app.config and debug it. Or you can add check to your code to make sure that you creating queue if it is not exists and add few minutes of sleep before verifying that notification has been received. As i mentioned you should not expect instant notification after job has been finished, Notification might start showing up after few minutes. Article describing notification feature -http://azure.microsoft.com/en-us/documentation/articles/media-services-check-job-progress/#check_progress_with_queues – George Trifonov May 11 '15 at 23:32
  • It continues to fail on this line, Assert.IsTrue(messages.Any()). It appears as if the messages are not entering the queue. I even set the delay Thread.Sleep for 10 minutes, still no messages in the queue. What could cause this? – user1790300 May 12 '15 at 01:53
  • When I go to the admin. site, in the content section, I see the uploaded content but the publish url is set to not published. Could this be the problem and if so what needs to occur programmatically to publish the video? – user1790300 May 12 '15 at 02:59
  • Are you able to debug through test uploaded to github ? If yes - do you see messages there? Messages are produced during encoding job and publishing should not affect notifications. – George Trifonov May 12 '15 at 14:18
  • I downloaded the code from github and am able to run it from the ShouldReceiveNotificationsForCompeletedJob test, I don't see any error messages in the output window, it just fails when it gets to this line: IEnumerable messages = queue.GetMessages(10); Assert.IsTrue(messages.Any()); – user1790300 May 12 '15 at 18:34
  • Contact me via twitter message https://twitter.com/GEOTRIF and we will take a look. – George Trifonov May 12 '15 at 20:26