本文整理汇总了C#中System.Messaging.Message.GetMessageId方法的典型用法代码示例。如果您正苦于以下问题:C# Message.GetMessageId方法的具体用法?C# Message.GetMessageId怎么用?C# Message.GetMessageId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Messaging.Message
的用法示例。
在下文中一共展示了Message.GetMessageId方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: HandlePeekedMessage
public bool HandlePeekedMessage(IMsmqTransport transport, OpenedQueue queue, Message message)
{
bool doesNotHaveMessageId = message.Extension.Length < 16;
if(doesNotHaveMessageId)
{
const string errorMessage = "Message does not have Extension set to at least 16 bytes, which will be used as the message id. Probably not a bus message.";
transport.RaiseMessageSerializationException(queue,message,errorMessage);
MoveToErrorQueue(queue, message, errorMessage);
return true;
}
var id = message.GetMessageId();
ErrorCounter errorCounter = null;
failureCounts.Read(reader => reader.TryGetValue(id, out errorCounter));
if (errorCounter == null)
return false;
if (errorCounter.FailureCount < numberOfRetries)
return false;
failureCounts.Write(writer =>
{
writer.Remove(id);
MoveToErrorQueue(queue, message, errorCounter.ExceptionText);
});
return true;
}
示例2: DeserializeMessages
protected object[] DeserializeMessages(OpenedQueue messageQueue, Message transportMessage, Action<CurrentMessageInformation, Exception> messageSerializationException)
{
try
{
return messageSerializer.Deserialize(transportMessage.BodyStream);
}
catch (Exception e)
{
try
{
logger.Error("Error when serializing message", e);
if (messageSerializationException != null)
{
var information = new MsmqCurrentMessageInformation
{
MsmqMessage = transportMessage,
Queue = messageQueue,
Message = transportMessage,
Source = messageQueue.RootUri,
MessageId = transportMessage.GetMessageId(),
Headers = transportMessage.Extension.DeserializeHeaders(),
};
messageSerializationException(information, e);
}
}
catch (Exception moduleEx)
{
logger.Error("Error when notifying about serialization exception", moduleEx);
}
throw;
}
}
示例3: CreateMessageInformation
private MsmqCurrentMessageInformation CreateMessageInformation(OpenedQueue queue,Message message, object[] messages, object msg)
{
return new MsmqCurrentMessageInformation
{
MessageId = message.GetMessageId(),
AllMessages = messages,
Message = msg,
Queue = queue,
TransportMessageId = message.Id,
Destination = Endpoint.Uri,
Source = MsmqUtil.GetQueueUri(message.ResponseQueue),
MsmqMessage = message,
TransactionType = queue.GetTransactionType()
};
}