本文整理汇总了C#中NServiceBus.TransportMessage类的典型用法代码示例。如果您正苦于以下问题:C# TransportMessage类的具体用法?C# TransportMessage怎么用?C# TransportMessage使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TransportMessage类属于NServiceBus命名空间,在下文中一共展示了TransportMessage类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UpdateExistingMessage
void UpdateExistingMessage(IDocumentSession session, string id, TransportMessage message)
{
var failedMessage = session.Load<Message>(id);
var timeOfFailure = DateTimeExtensions.ToUtcDateTime(message.Headers["NServiceBus.TimeOfFailure"]);
if (failedMessage.FailureDetails.TimeOfFailure == timeOfFailure)
{
return;
}
if (failedMessage.Status == MessageStatus.Successful && timeOfFailure > failedMessage.ProcessedAt)
{
throw new InvalidOperationException("A message can't first be processed successfully and then fail, Id: " + failedMessage.Id);
}
if (failedMessage.Status == MessageStatus.Successful)
{
failedMessage.FailureDetails = new FailureDetails(message);
}
else
{
failedMessage.Status = MessageStatus.RepeatedFailure;
failedMessage.FailureDetails.RegisterException(message);
}
session.SaveChanges();
}
示例2: MutateIncoming
public void MutateIncoming(TransportMessage transportMessage)
{
string bodyAsString = Encoding.UTF8
.GetString(transportMessage.Body);
Console.WriteLine("Serialized Message Body:");
Console.WriteLine(bodyAsString);
}
示例3: Handle
public bool Handle(TransportMessage message)
{
using (var session = Store.OpenSession())
{
session.Advanced.UseOptimisticConcurrency = true;
var failedMessage = new Message(message)
{
FailureDetails = new FailureDetails(message),
Status = MessageStatus.Failed,
ReplyToAddress = message.ReplyToAddress.ToString()
};
try
{
session.Store(failedMessage);
session.SaveChanges();
}
catch (ConcurrencyException) //there is already a message in the store with the same id
{
session.Advanced.Clear();
UpdateExistingMessage(session, failedMessage.Id, message);
}
}
Forwarder.Send(message, Settings.ErrorLogQueue);
return true;
}
示例4: Handle
public bool Handle(TransportMessage message)
{
using (var session = Store.OpenSession())
{
session.Advanced.UseOptimisticConcurrency = true;
var auditMessage = new Message(message);
auditMessage.MarkAsSuccessful(message);
try
{
session.Store(auditMessage);
session.SaveChanges();
}
catch (ConcurrencyException)
{
session.Advanced.Clear();
UpdateExistingMessage(session,auditMessage.Id, message);
}
}
return true;
}
示例5: MutateOutgoing
public void MutateOutgoing(LogicalMessage logicalMessage, TransportMessage transportMessage)
{
var headers = transportMessage.Headers;
if (headers.ContainsKey(Constants.Headers.Keys.Originator)) return;
headers.Add(Constants.Headers.Keys.Originator, Source);
}
示例6: MutateIncoming
public void MutateIncoming(TransportMessage transportMessage)
{
string bodyAsString = Encoding.UTF8
.GetString(transportMessage.Body);
log.Info("Serialized Message Body:");
log.Info(bodyAsString);
}
示例7: With_ProcessingEndpoint_header_should_return_processing_endpoint
public void With_ProcessingEndpoint_header_should_return_processing_endpoint()
{
var message = new TransportMessage(Guid.Empty.ToString(), new Dictionary<string, string>
{
{ Headers.ProcessingEndpoint ,"TheEndpoint"}
});
Assert.AreEqual("TheEndpoint",message.ProcessingEndpointName());
}
示例8: With_ReplyToAddress_should_return_ReplyToAddress
public void With_ReplyToAddress_should_return_ReplyToAddress()
{
var message = new TransportMessage
{
ReplyToAddress = new Address("TheEndpoint", "")
};
Assert.AreEqual("TheEndpoint",message.ProcessingEndpointName());
}
示例9: With_FailedQ_header_should_return_FailedQ
public void With_FailedQ_header_should_return_FailedQ()
{
var message = new TransportMessage(Guid.Empty.ToString(), new Dictionary<string, string>
{
{ "NServiceBus.FailedQ" ,"TheEndpoint"}
});
Assert.AreEqual("TheEndpoint",message.ProcessingEndpointName());
}
示例10: MutateOutgoing
public void MutateOutgoing(object[] messages, TransportMessage transportMessage)
{
var incomingContext = bus.CurrentMessageContext;
var incomingMessageId = incomingContext?.Headers["NServiceBus.MessageId"];
transportMessage.Headers
.Add("MutateTransportMessages_Outgoing", "ValueMutateTransportMessages_Outgoing");
}
示例11: No_headers_with_message_type_should_throw_with_message_id_and_types
public void No_headers_with_message_type_should_throw_with_message_id_and_types()
{
var message = new TransportMessage(Guid.Empty.ToString(), new Dictionary<string, string>
{
{ Headers.EnclosedMessageTypes ,"TheMessageType"}
});
var exception = Assert.Throws<Exception>(() => { message.ProcessingEndpointName(); });
Assert.AreEqual("No processing endpoint could be determined for message (00000000-0000-0000-0000-000000000000) with EnclosedMessageTypes (TheMessageType)", exception.Message);
}
示例12: MutateOutgoing
public void MutateOutgoing(LogicalMessage message, TransportMessage transportMessage)
{
log.Info("transportMessage.Body size before compression: " + transportMessage.Body.Length);
transportMessage.Body = Compress(transportMessage.Body);
transportMessage.Headers.Add(Constants.Headers.Keys.Compressed, Constants.Headers.Values.Compressed);
log.Info("transportMessage.Body size after compression: " + transportMessage.Body.Length);
}
示例13: MutateOutgoing
public void MutateOutgoing(object[] messages, TransportMessage transportMessage)
{
if (Bus.CurrentMessageContext == null)
return;
if (!Bus.CurrentMessageContext.Headers.ContainsKey("tenant"))
return;
transportMessage.Headers["tenant"] = Bus.CurrentMessageContext.Headers["tenant"];
}
示例14: MutateOutgoing
public void MutateOutgoing(LogicalMessage logicalMessage, TransportMessage transportMessage)
{
var command = logicalMessage.Instance as IOrderCommand;
if (command != null)
{
transportMessage.Headers[Headers.ConversationId] = command.OrderId;
}
}
示例15: HandleMessage
protected override void HandleMessage(TransportMessage message)
{
var destinationAddress = Address.Parse(message.Headers["ServiceControl.TargetEndpointAddress"]);
message.Headers.Remove("ServiceControl.TargetEndpointAddress");
message.Headers.Remove("ServiceControl.Retry.StagingId");
sender.Send(message, destinationAddress);
}