我目前正在使用Azure媒体服务和带有C#web api的Azure存储向应用程序添加视频服务。上传过程似乎工作正常,我可以从管理员那里看到作业成功完成的位置。控制台。
但是,如果我在调试器下运行应用程序,我会看到消息被添加到队列中以实际处理视频,但我从未在通知队列中收到任何消息。我一直在检查代码,但我没有看到任何似乎已关闭的内容。有没有人遇到过这个问题,或者对这个问题有什么看法?我目前正在调试模式下测试,我的连接字符串设置为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; }
}
答案 0 :(得分:0)
只需运行来自https://github.com/Azure/azure-sdk-for-media-services/blob/dev/test/net/Scenario/JobTests.cs的验证测试ShouldReceiveNotificationsForCompeletedJob即可验证通知工作流程。测试正在通过US WEST数据中心。
请注意,通过azure存储队列的作业通知并非设计为实时,您可以看到队列中的消息之间有几分钟的延迟。
粘贴与队列创建相关的代码:
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");