本文整理汇总了C#中Persistence.AckMessage方法的典型用法代码示例。如果您正苦于以下问题:C# Persistence.AckMessage方法的具体用法?C# Persistence.AckMessage怎么用?C# Persistence.AckMessage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Persistence
的用法示例。
在下文中一共展示了Persistence.AckMessage方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: HandleAck
private void HandleAck(HttpListenerContext ctx, CallInfo callInfo)
{
Logger.Debug("Received message ack for id: " + callInfo.ClientId);
var msg = new TransportMessage { ReturnAddress = inputQueue };
using (var scope = new TransactionScope(TransactionScopeOption.Required, new TransactionOptions { IsolationLevel = IsolationLevel.ReadCommitted, Timeout = TimeSpan.FromSeconds(30)}))
{
var p = new Persistence { ConnectionString = connString };
byte[] outMessage;
NameValueCollection outHeaders;
p.AckMessage(callInfo.ClientId, Convert.FromBase64String(callInfo.MD5), out outMessage, out outHeaders);
if (outHeaders != null && outMessage != null)
{
msg.Body = outMessage;
HeaderMapper.Map(outHeaders, msg);
if (msg.TimeToBeReceived < TimeSpan.FromSeconds(1))
msg.TimeToBeReceived = TimeSpan.FromSeconds(1);
msg.Recoverable = true;
if (String.IsNullOrEmpty(msg.IdForCorrelation))
msg.IdForCorrelation = msg.Id;
if (msg.MessageIntent == MessageIntentEnum.Init) // wasn't set by client
msg.MessageIntent = MessageIntentEnum.Send;
if (ctx.Request.Headers[HttpHeaders.FromKey] != null)
msg.Headers.Add(Headers.HttpFrom, ctx.Request.Headers[HttpHeaders.FromKey]);
string routeTo = Headers.RouteTo.Replace(HeaderMapper.NServiceBus + Headers.HeaderName + ".", "");
string destination;
if (msg.Headers.ContainsKey(routeTo))
destination = msg.Headers[routeTo];
else
destination = destinationQueue;
Logger.Info("Sending message to " + destination);
messageSender.Send(msg, destination);
}
scope.Complete();
}
ReportSuccess(ctx);
}