本文整理汇总了C#中MessagingFactory.CreateMessageSenderAsync方法的典型用法代码示例。如果您正苦于以下问题:C# MessagingFactory.CreateMessageSenderAsync方法的具体用法?C# MessagingFactory.CreateMessageSenderAsync怎么用?C# MessagingFactory.CreateMessageSenderAsync使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MessagingFactory
的用法示例。
在下文中一共展示了MessagingFactory.CreateMessageSenderAsync方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SendBookingRequests
static async Task SendBookingRequests(MessagingFactory senderMessagingFactory)
{
// and now we'll send some booking requests
dynamic bookingRequests = new dynamic[]
{
new
{
flight = new
{
bookingClass = "C",
legs = new[]
{
new {flightNo = "XB937", from = "DUS", to = "LHR", date = "2017-08-01"},
new {flightNo = "XB49", from = "LHR", to = "SEA", date = "2017-08-01"},
new {flightNo = "XB48", from = "SEA", to = "LHR", date = "2017-08-10"},
new {flightNo = "XB940", from = "LHR", to = "DUS", date = "2017-08-11"}
}
},
hotel = new {name = "Hopeman", city = "Kirkland", state = "WA", checkin = "2017-08-01", checkout = "2017-08-10"},
car = new {vendor = "Hervis", airport = "SEA", from = "2017-08-01T17:00", until = "2017-08-10:17:00"}
},
new
{
flight = new
{
bookingClass = "C",
legs = new[]
{
new {flightNo = "XL75", from = "DUS", to = "FRA", date = "2017-08-01"},
new {flightNo = "XL490", from = "FRA", to = "SEA", date = "2017-08-01"},
new {flightNo = "XL491", from = "SEA", to = "FRA", date = "2017-08-10"},
new {flightNo = "XL78", from = "FRA", to = "DUS", date = "2017-08-11"}
}
},
hotel = new {name = "Eastin", city = "Bellevue", state = "WA", checkin = "2017-08-01", checkout = "2017-08-10"},
car = new {vendor = "Avional", airport = "SEA", from = "2017-08-01T17:00", until = "2017-08-10:17:00"}
},
new
{
hotel = new {name = "Eastin", city = "Bellevue", state = "WA", checkin = "2017-08-01", checkout = "2017-08-10"}
},
new
{
flight = new
{
bookingClass = "Y",
legs = new[]
{
new {flightNo = "XL75", from = "DUS", to = "FRA", date = "2017-08-01"},
new {flightNo = "XL78", from = "FRA", to = "DUS", date = "2017-08-11"}
}
}
},
new
{
car = new {vendor = "Hext", airport = "DUS", from = "2017-08-01T17:00", until = "2017-08-10:17:00"}
}
};
Console.WriteLine("Sending requests");
var sender = await senderMessagingFactory.CreateMessageSenderAsync(SagaInputQueueName);
for (int j = 0; j < 5; j++)
{
for (int i = 0; i < bookingRequests.Length; i++)
{
var message = new BrokeredMessage(new MemoryStream(Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(bookingRequests[i]))))
{
ContentType = "application/json",
Label = "TravelBooking",
TimeToLive = TimeSpan.FromMinutes(15)
};
await sender.SendAsync(message);
Interlocked.Increment(ref pendingTransactions);
}
}
}