本文整理汇总了C#中NServiceBus.Unicast.Transport.TransportMessage类的典型用法代码示例。如果您正苦于以下问题:C# TransportMessage类的具体用法?C# TransportMessage怎么用?C# TransportMessage使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TransportMessage类属于NServiceBus.Unicast.Transport命名空间,在下文中一共展示了TransportMessage类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetUp
public void SetUp()
{
destination = Target.Input;
XmsUtilities.Purge(destination);
received = null;
sent = new TransportMessage().WithBody();;
}
示例2: Send
public void Send(TransportMessage message, Address address)
{
try
{
XmsAddress addr = address.ToXmsAddress();
using (var producer = provider.GetProducer(addr))
{
var xmsMessage = producer.CreateBytesMessage();
XmsUtilities.Convert(message, xmsMessage);
producer.Send(xmsMessage);
message.Id = xmsMessage.JMSMessageID;
}
}
// TODO: QueueNotFoundException
catch (Exception ex)
{
if (address == null)
throw new FailedToSendMessageException("Failed to send message.", ex);
throw new FailedToSendMessageException(
string.Format("Failed to send message to address: {0}@{1}", address.Queue, address.Machine), ex);
}
}
示例3: Defer
public void Defer(TransportMessage message, DateTime processAt, Address address)
{
message.Headers[ScheduledMessage.AMQ_SCHEDULED_DELAY] =
((int)processAt.Subtract(DateTime.UtcNow).TotalMilliseconds).ToString(CultureInfo.InvariantCulture);
this.MessageSender.Send(message, address);
}
示例4: MutateIncoming
public void MutateIncoming(TransportMessage transportMessage)
{
string bodyAsString = Encoding.UTF8
.GetString(transportMessage.Body);
Console.WriteLine("Serialized Message Body:");
Console.WriteLine(bodyAsString);
}
示例5: using
void ISendMessages.Send(TransportMessage message, Address address)
{
var queuePath = MsmqUtilities.GetFullPath(address);
using (var q = new MessageQueue(queuePath, QueueAccessMode.Send))
{
var toSend = MsmqUtilities.Convert(message);
toSend.UseDeadLetterQueue = UseDeadLetterQueue;
toSend.UseJournalQueue = UseJournalQueue;
if (message.ReplyToAddress != null)
toSend.ResponseQueue = new MessageQueue(MsmqUtilities.GetReturnAddress(message.ReplyToAddress.ToString(), address.ToString()));
try
{
q.Send(toSend, GetTransactionTypeForSend());
}
catch (MessageQueueException ex)
{
if (ex.MessageQueueErrorCode == MessageQueueErrorCode.QueueNotFound)
throw new QueueNotFoundException { Queue = address };
throw;
}
message.Id = toSend.Id;
}
}
示例6:
void IManageMessageFailures.ProcessingAlwaysFailsForMessage(TransportMessage message, Exception e)
{
if (SanitizeProcessingExceptions)
e = ExceptionSanitizer.Sanitize(e);
this.SendFailureMessage(message, e, "ProcessingFailed");
}
示例7: CloneAndSendLocal
void CloneAndSendLocal(TransportMessage messageToDispatch, Site destinationSite)
{
//todo - do we need to clone? check with Jonathan O
messageToDispatch.Headers[Headers.DestinationSites] = destinationSite.Key;
messageSender.Send(messageToDispatch, localAddress);
}
示例8: IncrementFailuresForMessage
public void IncrementFailuresForMessage(TransportMessage message, Exception e)
{
var item = failuresPerMessage.AddOrUpdate(message.Id, s => new Tuple<int, Exception>(1, e),
(s, i) => new Tuple<int, Exception>(i.Item1 + 1, e));
notifications.Errors.InvokeMessageHasFailedAFirstLevelRetryAttempt(item.Item1, message, e);
}
示例9: TryInvokeFaultManager
private bool TryInvokeFaultManager(TransportMessage message, Exception exception)
{
try
{
Exception e = exception;
if (e is AggregateException)
{
e = e.GetBaseException();
}
if (e is TransportMessageHandlingFailedException)
{
e = e.InnerException;
}
message.RevertToOriginalBodyIfNeeded();
failureManager.ProcessingAlwaysFailsForMessage(message, e);
return true;
}
catch (Exception ex)
{
Configure.Instance.RaiseCriticalError(
String.Format("Fault manager failed to process the failed message with id {0}", message.Id), ex);
}
return false;
}
示例10:
void IMutateOutgoingTransportMessages.MutateOutgoing(IMessage[] messages, TransportMessage transportMessage)
{
if (transportMessage.Headers.ContainsKey(WindowsIdentityName))
transportMessage.Headers.Remove(WindowsIdentityName);
transportMessage.Headers.Add(WindowsIdentityName, Thread.CurrentPrincipal.Identity.Name);
}
示例11: ToEventData
private static EventData ToEventData(TransportMessage transportMessage, EventStoreMessageMetadata metadata)
{
metadata.CorrelationId = transportMessage.CorrelationId;
metadata.MessageId = transportMessage.Id;
metadata.ReplyTo = transportMessage.ReplyToAddress.ToString();
metadata.Headers = transportMessage.Headers;
var type = transportMessage.IsControlMessage()
? "ControlMessage"
: transportMessage.Headers[Headers.EnclosedMessageTypes];
byte[] data;
string contentType;
if (transportMessage.Headers.TryGetValue(Headers.ContentType, out contentType))
{
if (contentType != ContentTypes.Json)
{
throw new InvalidOperationException("Invalid content type: "+contentType);
}
data = transportMessage.Body;
}
else
{
data = new byte[0];
}
return new EventData(Guid.NewGuid(), type, true, data, metadata.ToJsonBytes());
}
示例12: MutateIncoming
public void MutateIncoming(TransportMessage transportMessage)
{
string bodyAsString = Encoding.UTF8
.GetString(transportMessage.Body);
log.Info("Serialized Message Body:");
log.Info(bodyAsString);
}
示例13: Send
public void Send(TransportMessage message, string destination)
{
var address = MsmqUtilities.GetFullPath(destination);
using (var q = new MessageQueue(address, QueueAccessMode.Send))
{
var toSend = new Message();
if (message.Body != null)
toSend.BodyStream = new MemoryStream(message.Body);
if (message.CorrelationId != null)
toSend.CorrelationId = message.CorrelationId;
toSend.Recoverable = message.Recoverable;
toSend.UseDeadLetterQueue = UseDeadLetterQueue;
toSend.UseJournalQueue = UseJournalQueue;
if (!string.IsNullOrEmpty(message.ReturnAddress))
toSend.ResponseQueue = new MessageQueue(MsmqUtilities.GetReturnAddress(message.ReturnAddress, destination));
if (message.TimeToBeReceived < MessageQueue.InfiniteTimeout)
toSend.TimeToBeReceived = message.TimeToBeReceived;
if (message.Headers == null)
message.Headers = new Dictionary<string, string>();
if (!message.Headers.ContainsKey(HeaderKeys.IDFORCORRELATION))
message.Headers.Add(HeaderKeys.IDFORCORRELATION, null);
if (String.IsNullOrEmpty(message.Headers[HeaderKeys.IDFORCORRELATION]))
message.Headers[HeaderKeys.IDFORCORRELATION] = message.IdForCorrelation;
using (var stream = new MemoryStream())
{
headerSerializer.Serialize(stream, message.Headers.Select(pair => new HeaderInfo { Key = pair.Key, Value = pair.Value }).ToList());
toSend.Extension = stream.GetBuffer();
}
toSend.AppSpecific = (int)message.MessageIntent;
try
{
if (MsmqUtilities.CurrentTransaction != null)
q.Send(toSend, MsmqUtilities.CurrentTransaction);
else
q.Send(toSend, GetTransactionTypeForSend());
}
catch (MessageQueueException ex)
{
if (ex.MessageQueueErrorCode == MessageQueueErrorCode.QueueNotFound)
throw new QueueNotFoundException { Queue = destination };
throw;
}
message.Id = toSend.Id;
}
}
示例14: SerializationFailedForMessage
public void SerializationFailedForMessage(TransportMessage message, Exception e)
{
if (_logger.IsDebugEnabled)
{
_logger.Debug(string.Format("Serialization failed for message {0} -- persisting to failure store.", message.Id));
}
Save(new FailureInfo(message, e, true));
}
示例15: ProcessingAlwaysFailsForMessage
public void ProcessingAlwaysFailsForMessage(TransportMessage message, Exception e)
{
if (_logger.IsDebugEnabled)
{
_logger.Debug(string.Format("All processing attempts failed for message {0} -- pesisting to failure store.", message.Id));
}
Save(new FailureInfo(message, e, false));
}