我正在使用JavaScript向事件中心发送Ajax XHR消息......
$.ajax({
type: "POST",
url: eventHubConfig.ServiceBusUri + eventHubConfig.AdHubName + "/messages/?timeout=60",
data: JSON.stringify(payload),
cache: false,
contentType: "application/json",
beforeSend: function(xhr) {
xhr.setRequestHeader("Authorization", SASToken);
xhr.setRequestHeader("Content-Type", "application/json");
}
});
Payload是一个简单的对象,字符串化为JSON格式,如...
var payload = {
platformId: 2,
articleId: 3,
...
...
Type: "ViewType"
};
从事件中心读取时的消息如下所示..
偶尔我收到的消息看起来像......
请注意,从C#后端的Microsoft.ServiceBus.Messaging.EventData对象获取UTF8字符串后,这些都是消息正文...
var jsonString = Encoding.UTF8.GetString(eventData.GetBytes());
有关Event Hub如何接收第二条消息的任何想法?