本文整理匯總了C#中System.Globalization.Message.GetDeliveryTag方法的典型用法代碼示例。如果您正苦於以下問題:C# Message.GetDeliveryTag方法的具體用法?C# Message.GetDeliveryTag怎麽用?C# Message.GetDeliveryTag使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Globalization.Message
的用法示例。
在下文中一共展示了Message.GetDeliveryTag方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: PublishMessage
/// <summary>
/// Publishes the message.
/// </summary>
/// <param name="message">The message.</param>
/// <param name="headers">User specified message headers.</param>
/// <param name="regenerate">Generate new unique message identifier.</param>
public void PublishMessage(Message message, int delayMilliseconds)
{
var messageId = message.Id;
var deliveryTag = message.Header.Bag.ContainsKey(HeaderNames.DELIVERY_TAG) ? message.GetDeliveryTag().ToString() : null;
var headers = new Dictionary<string, object>
{
{HeaderNames.MESSAGE_TYPE, message.Header.MessageType.ToString()},
{HeaderNames.TOPIC, message.Header.Topic},
{HeaderNames.HANDLED_COUNT, message.Header.HandledCount.ToString(CultureInfo.InvariantCulture)},
};
message.Header.Bag.Each((header) =>
{
if (!HeadersToReset.Any(htr => htr.Equals(header.Key))) headers.Add(header.Key, header.Value);
});
if (!String.IsNullOrEmpty(deliveryTag))
headers.Add(HeaderNames.DELIVERY_TAG, deliveryTag);
if (delayMilliseconds > 0)
headers.Add(HeaderNames.DELAY_MILLISECONDS, delayMilliseconds);
_channel.BasicPublish(
_exchangeName,
message.Header.Topic,
false,
false,
CreateBasicProperties(messageId, message.Header.TimeStamp, headers),
Encoding.UTF8.GetBytes(message.Body.Value));
}